从类别数组获取帖子
我有一些特定类别的 id。我想一次性循环这个类别和最后 3 个帖子。我尝试了这个,但只来自数组中的一个类别。
<?php
$args = array(
'cat' => 48,43,49,46,47,44,51,50,42,
'order' => 'ASC',
'showposts' => 3
);
query_posts($args);
?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
I have some certain categories' ids. I want to loop this categories and last 3 posts in one time. I try this but only come one category from array.
<?php
$args = array(
'cat' => 48,43,49,46,47,44,51,50,42,
'order' => 'ASC',
'showposts' => 3
);
query_posts($args);
?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这段代码不起作用:
'cat' => 48,43,49,46,47,44,51,50,42,
您必须使用数组
'cat' =>;数组(48,43,49,46,47,44,51,50,42),
This piece of code won't work:
'cat' => 48,43,49,46,47,44,51,50,42,
You'll have to use an array
'cat' => array(48,43,49,46,47,44,51,50,42),
由于某种原因“猫”不起作用。我们使用过
并且效果很好。
完成的工作代码:
For some reason 'cat' did not work. We used
and it workined fine.
The completed working code:
您可以获取您想要发布的类别中的所有帖子。
您可以根据您的期望找到帖子。
You can get All Posts in a Category which one you want publish.
You can find post as per your expectation by.
根据你的代码。更新 -
According to your code. Update --
实际上应该是:
'猫' => '48,43,49,46,47,44,51,50,42'
should actually be:
'cat' => '48,43,49,46,47,44,51,50,42'