Php 仅显示特定类别的帖子
我是wordpress开发的新手,所以我不得不面对为特定类别显示一些帖子的问题 就像,我正在添加(张贴)一些图片到数据库中的后期图片类别 现在在前端,我有一个页面名为Picture Mania,我只想显示我添加到post_图片类别中的那些图片 为此,我首先安装了,现在我正试图通过此代码检索该页面上的desire类别图像Php 仅显示特定类别的帖子,php,wordpress,Php,Wordpress,我是wordpress开发的新手,所以我不得不面对为特定类别显示一些帖子的问题 就像,我正在添加(张贴)一些图片到数据库中的后期图片类别 现在在前端,我有一个页面名为Picture Mania,我只想显示我添加到post_图片类别中的那些图片 为此,我首先安装了,现在我正试图通过此代码检索该页面上的desire类别图像 <?php query_posts('post_picture =post_picture&showposts=5'); while (have_posts())
<?php query_posts('post_picture =post_picture&showposts=5');
while (have_posts()) : the_post();
// do whatever you want
?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php cup_post_nav(); ?>
<?php comments_template(); ?>
<b><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
<?php
endwhile;
?>
它工作良好,但显示所有类别的图像,所以结论我没有得到我的愿望输出
非常感谢您的回答。…并且提前感谢您的帮助显示特定类别的帖子,您可以在
query\u posts()中添加cat=YOUR\u category\u ID
,如:
query_posts('post_picture=post_picture&showposts=5&cat=$your_Category_Id');
如示例中显示特定类别的帖子,您可以在query\u posts()
中添加cat=YOUR\u category\u ID
,如:
query_posts('post_picture=post_picture&showposts=5&cat=$your_Category_Id');
如示例所示,尝试以下操作:
<?php query_posts('cat=your-post_picture-category-id&showposts=5');
while (have_posts()) : the_post();
// do whatever you want
?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php cup_post_nav(); ?>
<?php comments_template(); ?>
<b><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>">
<?php the_title(); ?></a>
试试这个:
<?php query_posts('cat=your-post_picture-category-id&showposts=5');
while (have_posts()) : the_post();
// do whatever you want
?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php cup_post_nav(); ?>
<?php comments_template(); ?>
<b><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>">
<?php the_title(); ?></a>
您可以传递类别id(cat=3),例如
查询/发布参考:
虽然建议使用此方法代替查询帖子,但您可以传递类别id(cat=3),例如
查询/发布参考:
虽然是推荐的方法,而不是查询帖子