【发布时间】:2010-01-24 18:11:26
【问题描述】:
我的问题不在于 Wordpress 的 WPDB 类,而在于 MySQL 语法。我正在尝试使以下序列起作用:
- 获取所有帖子 ID 的数组
- 过滤掉来自特定类别的帖子
- 过滤掉重复、修订、草稿等。仅显示已发布的内容。
帮助?谢谢。
【问题讨论】:
我的问题不在于 Wordpress 的 WPDB 类,而在于 MySQL 语法。我正在尝试使以下序列起作用:
帮助?谢谢。
【问题讨论】:
通过将类别 ID 或类别名称传递给该 http://codex.wordpress.org/Template_Tags/query_posts,使用 query_posts 函数。这一切都在链接上进行了解释。
在你的 cmets 之后编辑:
您也可以使用 get_posts http://codex.wordpress.org/Template_Tags/get_posts,AFAIK 它们都返回数组。
$posts = get_posts('category=1');
foreach($posts as $post) {
echo $post->ID; // or whatever you want to do with it...
}
【讨论】: