views:

33

answers:

1

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.

+2  A: 

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...
}
robertbasic
I need to get this into an Array so I can further work with it. Displaying is not the issue here, rather the gathering of this data.
konzepz
I specifically need the IDs of all posts, in an array, so I can divide them into groups, and then create a manipulated pagination feature.
konzepz
This is the best solution. Use get_posts or query_posts to retrieve the posts that you need. get_posts returns an array of posts matching the criteria. Then, just look through it and grab the IDs and divide them into groups if you want. If you actually posted what you wanted, perhaps I could give a more detailed solution.
nickohrn