Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

Any suggestions for the "best way"?

Thx.

share|improve this question

3 Answers 3

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.

share|improve this answer

The "Best Way" would be with a custom page template. Just like index.php loops through all the posts, you can run a custom query to loop through everything and only echo the information you want (title, URL) to the browser.

Here are some good tutorials for building a custom page template:

share|improve this answer
    
Thanks for the links, which lead me to the solution I ended up with below. I'd upvote this answer but apparently I don't have enough SE mojo built up yet ;?) –  cpuguru Sep 1 '10 at 12:33
up vote 2 down vote accepted

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:

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.