In: , , , ,
On: 2008 / 02 / 11 Viewed: 74285 times
Shorter URL for this post:
  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:


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. 1
    Ben Tremblay Canada »
    said, on 12/Feb/08 at 8:27 pm # :

    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. 2
    Lorelle United States »
    replied, on 14/Feb/08 at 4:08 am # :

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

  3. 3
    John A. Bilicki III United States »
    thought, on 12/Apr/08 at 1:10 am # :

    Lorelle, you can add categories, find the number or name of your category on a category link and then check out this page…

    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. 4
    John A. Bilicki III United States »
    replied, on 12/Apr/08 at 4:10 am # :

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

    1. query_posts("posts_per_page=-1&year=2008");
  5. 5
    Kitkat Malaysia »
    said, on 03/Dec/08 at 12:58 pm # :

    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

Comment Guidelines or Die

  • HTML: You can use these tags: <a href=""> <em> <i> <b> <strong> <blockquote>
  • Posting code: Post raw code (no <> &lt; etc) within appropriate tags : [php][/php], [css][/css], [html][/html], [js][/js], [sql][/sql], [xml][/xml], or generic [code][code]
  • Gravatars: Curious about the little images next to each commenter's name ? Go to Gravatar.
  • Spam: Various spam plugins on patrol. I'll put pins in a Voodoo doll if you spam me.
  • I will mark as Spam test comments, all comments with SEO names (ie "My Cool Online Shop" instead of "Joe") or containing forum-like signatures.

Read more ?