Using WP_Query in WordPress 2.7

So I was trying for the last week or so to use three loops on a single page, to display categorized pages, and couldn’t figure out why it didn’t work. (I used the plugin page category plus to put pages in categories).

Anyways, if you want pages to be shown in a categorical listing, use post_type=page in the query string. Otherwise it’ll only show posts by default, which didn’t happen in previous versions! Mine looked like this: <?php $sportsQuery = new WP_Query(‘category_name=Sports Pages&post_type=page’); ?>

//Loop goes here…

Hope this helps somebody. I know I’ll be coming back to it when I forget!

For more info see: http://codex.wordpress.org/Template_Tags/query_posts


Leave a Reply