A LOOP with multiple custom post types and $query_string
-
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();
…the
$query_string
won’t work when using thearray
method. Like it says hereIf 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 ??
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘A LOOP with multiple custom post types and $query_string’ is closed to new replies.