Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 仅显示特定类别的帖子_Php_Wordpress - Fatal编程技术网

Php 仅显示特定类别的帖子

Php 仅显示特定类别的帖子,php,wordpress,Php,Wordpress,我是wordpress开发的新手,所以我不得不面对为特定类别显示一些帖子的问题 就像,我正在添加(张贴)一些图片到数据库中的后期图片类别 现在在前端,我有一个页面名为Picture Mania,我只想显示我添加到post_图片类别中的那些图片 为此,我首先安装了,现在我正试图通过此代码检索该页面上的desire类别图像 <?php query_posts('post_picture =post_picture&showposts=5'); while (have_posts())

我是wordpress开发的新手,所以我不得不面对为特定类别显示一些帖子的问题

就像,我正在添加(张贴)一些图片到数据库中的后期图片类别

现在在前端,我有一个页面名为Picture Mania,我只想显示我添加到post_图片类别中的那些图片

为此,我首先安装了,现在我正试图通过此代码检索该页面上的desire类别图像

<?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),例如

查询/发布参考:

虽然是推荐的方法,而不是查询帖子