在sigle.php
页面中,我需要显示属于帖子类别的帖子列表,我必须显示帖子内容。
所以我做了一个查询,以便将帖子归属于帖子类别:
<?php
$cat = get_the_category();
query_posts('cat='.$cat[0]->cat_ID);
while (have_posts()) : the_post();?>
<li <?php echo get_the_ID() == get_query_var('p') ? 'class="current-menu-item"' : '';?>><a href="<?php echo the_permalink();?>"><?php echo get_the_title();?></a></li>
<?php endwhile;?>
现在我该如何检索当前的帖子数据? 如果我喜欢这个
<?php while ( have_posts() ) : the_post(); ?>
<?php echo the_post_thumbnail(get_the_ID());?>
<?php endwhile;?>
我仍然显示query_posts
。
答案 0 :(得分:1)
我使用=/2
代替WP_Query
;
query_posts()