这可能吗?如果我写了一篇文章并将其放入“时尚”类别,我希望它进入我制作的“时尚”页面。我该怎么做?我有点犹豫不决,因为我看到在发表帖子时可以选择多个类别。。。
我如何才能让某个类别中的新帖子进入某个页面?
1 个回复
SO网友:Johansson
你的意思是你想制作一个页面并在其中显示你的时尚类帖子?
当然,这很简单。假设您的时尚类别ID为123,您可以尝试以下操作:
$args = array(
\'posts_per_page\' => 10,
\'cat\' => \'123\',
);
$fashion_query = new WP_Query($args);
if ( $fashion_query->have_posts() ) {
while ( $fashion_query->have_posts() ) : the_post();
the_content();
endwhile;
}
wp_reset_query();
为喜欢的页面创建一个PHP文件,然后将上面的代码复制到页面模板中的任何位置。