I’ve been reading about multiple loops, and have been using query_posts up until now.
So now I read here http://codex.wordpress.org/The_Loop that it’s necessary to use wp_query, along the lines of
<?php $first_loop = new WP_Query('showposts=200&cat=24&orderby=rand'); while ($first_loop->have_posts()) : $first_loop->the_post(); DO STUFF endwhile;
The problem with this is that there’s no if.. else, so that if there are no posts, an error message is displayed. (I want an error message if there are no posts)
What do I do?
Also, second question, it’s not made clear here http://codex.wordpress.org/Function_Reference/WP_Query what parameters wp_query can take.
Are they exactly the same parameters as query_post?
Third question, query_post uses
$query_string .to preserve information passed via a link. Is there an equivalent for wp_query?
- The topic ‘wp_query’ is closed to new replies.