【问题标题】:Error in search terms搜索字词错误
【发布时间】:2018-01-22 16:13:50
【问题描述】:

我想得到一些帮助。我的网站在搜索某些内容时不匹配并显示:

注意:试图在 /customers/3/a/2/**********ia.com/httpd.www/wp-content/themes.../ 中获取非对象的属性assets.php 在第 741 行

在那一行是:

    if ( $is_product || is_post_type_archive( 'nitro-gallery' ) || is_singular( 'nitro-gallery' ) || ( is_single() && 'gallery' == $format ) || is_tax( 'gallery_cat' ) || has_shortcode( $post->post_content, 'product_page' ) ) {
        wp_enqueue_style( 'nivo-lightbox' );
        wp_enqueue_script( 'nivo-lightbox' );
    }

【问题讨论】:

  • 你应该用 is_product() 替换 $is_product ......它应该会更好。
  • 我只能猜测$post 不是一个对象。使用 var_dump($post); 验证其中包含的内容
  • 大家好,通过 is_product() 改变 $is_product 没什么...
  • 我不明白 var_dump($post);我该怎么办?
  • 您可以简单地尝试在 if 语句中逐个添加条件,直到找到罪魁祸首。

标签: php wordpress search woocommerce product


【解决方案1】:

在 if 语句之前添加以下行:

global $post;

【讨论】:

    猜你喜欢
    • 2017-05-19
    • 1970-01-01
    • 1970-01-01
    • 2021-10-05
    • 2017-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多