Loop like this…
global $query_string; $posts = query_posts($query_string . 'posts_per_page=3&post_type=music'); if (have_posts()) : while (have_posts()) : the_post();
…works great! Keeps the original query around and pagination works. But it has all the post types in it. I have 4 custom post types. I would like to exclude the pages.
This loop display the custom post types and posts, but not pages. But…
query_posts(array('posts_per_page' => 3, 'post_type' => array('recommendations', 'posts', 'photos', 'food', 'music'))); if (have_posts()) : while (have_posts()) : the_post();
$query_stringwon’t work when using the
arraymethod. Like it says here
If you don’t need to use the $query_string variable, another method exists that is more clear and readable, in some more complex cases. This method puts the parameters into an array.
Thanks for all the help 🙂
- The topic ‘A LOOP with multiple custom post types and $query_string’ is closed to new replies.