Create an “All Posts” or “Archives” Page with WordPress 3.0?

I’d like to create an “All Posts” page on the Ocean Bytes blog that contains an unordered list of all Titles of the posts to date, with each title hyperlinking to its blog post.

There appear to be several plugins that do something like this, but most do not list WordPress 3.0+ as supported yet, or they want to subset the blog postings by Year and then Month which is not desired.

Read More

Any suggestions for the “best way”?

Thx.

Related posts

Leave a Reply

3 comments

  1. Create a new template file and do this as the loop:

    query_posts( array( 'posts_per_page' => -1, 'post_status' => 'publish' ) );
    if( have_posts() ):
      echo '<ul>';
      while( have_posts() ):
        the_post();
        echo '<li><a href="';
        the_permalink();
        echo '">';
        the_title();
        echo '</a></li>';
      endwhile;
      echo '</ul>';
    endif;
    wp_reset_query();
    

    Then just use that template for a page and it’ll automatically generate the page. Check out the codex page for query_posts() for more information on how to change the query.

  2. I ended up creating a page template called “allposts-page.php” in the Twenty-Ten Themes folder containing the following code:

    <?php
    /**
     * Template Name: All Posts
     *
     * A custom page template for displaying all posts.
     *
     * The "Template Name:" bit above allows this to be selectable
     * from a dropdown menu on the edit page screen.
     *
     * @package WordPress
     * @subpackage Twenty_Ten
     * @since Twenty Ten 1.0
     */
    
    get_header(); ?>
    
      <div id="container">
       <div id="content" role="main">
    <h2>Archive of All Posts:</h2>
      <ul>
        <?php wp_get_archives('type=postbypost'); ?>
      </ul>
    
    
       </div><!-- #content -->
      </div><!-- #container -->
    
    <?php get_footer(); ?>
    

    I then created a new page using the WordPress Admin system with a title of “All Posts” and selected the “All Posts” template from the drop-down. Didn’t need to enter anything in the body.

    The resulting page can be found via:

    http://www.oceanbytes.org/all-posts/

    The default for “wp_get_archives” is “monthly” but I chose “postbypost” as I wanted to just list all posts as on long list. More options can be found on the WordPress site via Function Reference/wp get archives