There must be a more elegant way to handle this, but, I can’t figure it out!
Basically, I wish to create a sitemap on my 404 page, using multiple loops to grab the titles of posts by category and display in a list.
This is the code I have used (in fact I use a new query 6 times, once for each category):
$books = new WP_Query('category_name=recommended-books');
while ($books->have_posts()) : $books->the_post();
$permalink = get_permalink($books->ID);
">< ?php the_title(); ?>
< ?php endwhile; ?>
Which works fine, except it only creates a list of the latest “10” posts and I would like the COMPLETE list of posts.
The simple, and not so elegant way to handle this would be to add:
to the new WP_Query string, and that works of course, however, does anyone know of a more elegant and less “hackish” solution to this?
I believe you can set the property $post_count for WP_Query, as stated here. Perhaps try setting that to 10?
But I want the COMPLETE list of posts – not just 10!
LOL! 1 post is even sillier!
Chris didn’t say 1 post per page, he said -1.
We should have emoticon here that says: I’m with stupid so I can use that on myself. Sorry @cjk, I must’ve read wrong, I hope Chris’ answer is helpfull for you.
OOPS! My apologies then! ;-)
So, I’ll give it a whirl, but why -1?
-1 is WordPress’ way of saying “all”. Just the way it is.
I would never have guessed and I didn’t see anything in the Codex to suggest it.
Odd though, in this case it says “all” yet when we use it in the regular loop for Categories, for example, -1 would be saying get all categories except #1. Yes?
You must be logged in to reply to this topic.
*May or may not contain any actual "CSS" or "Tricks".