WordPress:显示特定类别的所有帖子 [英] WordPress: Show all posts from specific category

查看:87
本文介绍了WordPress:显示特定类别的所有帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要显示WordPress中指定类别的最新帖子。

I Need to show latest post from a specified category in WordPress.

该类别为新闻世界,我正在尝试这段代码,但向我展示所有帖子

The category is " News World ", and I am try this code but show me all post from all category.

$wp_query = new WP_Query( array(
                'post_type' => 'post',
                'paged' => $paged
            ) );


推荐答案

<?php $custom_query = new WP_Query('cat=9'); //your category id 
while($custom_query->have_posts()) : $custom_query->the_post(); ?>

    //loop items go here

<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>

这篇关于WordPress:显示特定类别的所有帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆