WP_Query loop problem
-
i have my settings to show only 10 posts per page.
for a particular template tag, i wanted to show all the posts. i assumed and went ahead and made another tag page with a new loop.
<ol><?php $recent = new WP_Query("tag=2009&showposts=40&orderby=title&order=ASC"); while($recent->have_posts()) : $recent->the_post();?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> </ol>
the loop works great, BUT i don’t know how to show ALL the posts; right now i’m only showing 40. is there a variable I can put that will show all?
my other question is i can’t figure out how to show an error message if no posts exist for that tag. (sorry, no posts matched your criteria)
i tried using
<?php endwhile; else: ?> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?> <p><?php posts_nav_link(' — ', __('« Previous Page'), __('Next Page »')); ?></p>
but i keep getting syntax errors.
any help is appreciated.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘WP_Query loop problem’ is closed to new replies.