在wordpress中显示帖子查询结果后显示当前帖子

时间:2015-11-05 10:22:42

标签: wordpress post wordpress-theming

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

1 个答案:

答案 0 :(得分:1)

我使用=/2代替WP_Query;

解决了问题
query_posts()