开发者

Need help with MySQL query for Wordpress

My problem is not with Wordpress's WPDB class, but with the开发者_开发技巧 MySQL syntax. I'm trying make the following sequence work:

  • Get an array of all Posts IDs
  • Filter out posts from a specific Category
  • Filter out duplicates, revisions, drafts etc. Only show Published content.

Help? Thank you.


Use query_posts function for that http://codex.wordpress.org/Template_Tags/query_posts by passing the category id or the category name to it. It's all explained on the link.

Edit after your comments:

You can use get_posts http://codex.wordpress.org/Template_Tags/get_posts, too, AFAIK they both return arrays.

$posts = get_posts('category=1');
foreach($posts as $post) {
    echo $post->ID; // or whatever you want to do with it...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜