WordPress Tip: Modifying the Loop, Custom Posts Query to include all Post Types

The default post_type in query_posts is ‘post’, so other post types will not be in the loop unless they are specified. Here is an example of what you could include at the top of your template to include all post types.


global $wp_query;
$p = array('post_type' => array('article', 'gallery','post','project'));
$q = array_merge($wp_query->query_vars, $p);
query_posts($q);

This entry was posted in Code, Hacking. Bookmark the permalink.

Comments are closed.