所以我有一个关于类别的基本循环。显示特定类别中所有帖子的php,如下所示:
<?php if (have_posts()) :
while(have_posts()): the_post();
?>
<a href="<?php the_permalink(); ?>">
<div>
<h3><?php echo the_title();?></h3>
<p><?php echo the_content(); ?></p>
</div>
</a>
<?php
endwhile;
endif;
?>
我在另一个页面上有另一个循环,显示最受欢迎的帖子(按喜欢的帖子数量排序)。该循环是:
<?php
$query_args = array(
\'post_type\' => \'post\',
\'posts_per_page\' => 2,
\'orderby\' => \'meta_value\',
\'order\' => \'DESC\',
\'meta_query\' => array(
\'relation\' => \'OR\',
array(
\'key\' => \'Likes\',
\'compare\' => \'NOT EXISTS\',
\'type\' => \'numeric\'
),
array(
\'key\' => \'Likes\',
\'compare\' => \'EXISTS\',
\'type\' => \'numeric\'
)
)
);
$loop = new WP_Query($query_args);
if ($loop->have_posts()):
while($loop->have_posts()):
$loop->the_post();
?>
<a href="<?php the_permalink(); ?>">
<div>
<h3><?php echo the_title();?></h3>
<p><?php echo the_content(); ?></p>
</div>
</a>
<?php
endwhile;
endif;
?>
所以现在我想在类别内创建另一个循环。php,它根据喜欢的数量显示特定类别中的帖子,或者换句话说,显示该类别中的热门帖子。如何将这两个循环结合起来以实现这一点?我们将非常感谢您的帮助。
干杯