In: , , , ,
On: 2008 / 02 / 11
Shorter URL for this post: http://ozh.in/gv
  1. query_posts($query_string.'posts_per_page=-1');
  2.        while(have_posts()) {
  3.        the_post();
  4.        the_time();
  5.        the_title();
  6. }

This will display the time and title for all your posts. This could result in a very long page, and a more usable way of doing it would be to change the posts_per_page parameter, and add Next and Previous links to navigate the whole list. Code snippet by Otto in the wp-hackers mailing list.

Shorter URL

Want to share or tweet this post? Please use this short URL: http://ozh.in/gv

Metastuff

This entry "WordPress Snippet: Complete List of Posts" was posted on 11/02/2008 at 9:22 am and is tagged with , , , ,
Watch this discussion : Comments RSS 2.0.

5 Blablas

  1. Ben Tremblay says:

    Yaa … great example of "snippet".

    You've got me redthinking my Codex page on "The Loop" … granularity … a ton of good links to a ton of good pages, but it's all too massive.

    Now, a collection of snippets ordered by funtionality or hooks or something … /that/ would be neat!

  2. Lorelle says:

    Brilliant, as usual. Is there a way to set this by category rather than date? That would be really useful.

  3. Lorelle, you can add categories, find the number or name of your category on a category link and then check out this page…
    http://codex.wordpress.org/Template_Tags/query_posts#Category_Parameters

    I'm actually having a little trouble getting all the posts to display from 2008…

    1. query_posts('posts_per_page=-1'&'year=2008');

    When I designate the poss_per_page alone it will display all the posts I've made since I started my blog…but that defeats the purpose of specifying a year! Ideas?

  4. I was adding extra quotes where it's more like an HTTP query…

    1. query_posts("posts_per_page=-1&year=2008");
  5. Kitkat says:

    Thanks for the tips. I was looking for a way to display all the posts on a blog of mine, this helps a lot!

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Gravatars: Curious about the little images next to each commenter's name ? Go to Gravatar and sign for a free account
Spam: Various spam plugins may be activated. I'll put pins in a Voodoo doll if you spam me.

Read more ?