Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Wordpress发布的查询中使用WooCommerce标题_Wordpress_Woocommerce - Fatal编程技术网

在Wordpress发布的查询中使用WooCommerce标题

在Wordpress发布的查询中使用WooCommerce标题,wordpress,woocommerce,Wordpress,Woocommerce,我正在尝试使用: <?php $title_reviews = get_the_title(); $title_reviews = strtolower($title_reviews); query_posts('category_name=$title_reviews&posts_per_page=4'); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <li

我正在尝试使用:

<?php $title_reviews = get_the_title(); $title_reviews = strtolower($title_reviews); query_posts('category_name=$title_reviews&posts_per_page=4'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li class="reviews-posts"><?php the_content(); ?></li>
<?php endwhile; endif; wp_reset_query(); ?>

  • 但它不会返回任何结果——例如,我在Reviews类别下有一个名为Product1(子类别)的类别。如果我只是在类别名称中使用product1,效果很好,但我正在尝试为每个产品页面动态设置此筛选器。

    query_posts('posts_per_page=4&category_name=' . $title_reviews);
    
    已解决:

    query_posts('posts_per_page=4&category_name=' . $title_reviews);
    

    请不要使用
    query\u posts()
    。请阅读帖子查询…请不要使用
    query\u posts()
    。请阅读后查询。。。