WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I currently have a new custom post type-- "Books." I have a custom rewrite url that I set when registering my post type:

'rewrite' => array( 'slug' => 'books', 'with_front' => false )

It works great when I visit a specific post, but how do I take control of the /books url for displaying a list of ALL of the books by date posted?

share|improve this question
up vote 2 down vote accepted

Once way of doing it - I am sure there are other ways too - is to make a page template for books: books.php You can make a copy of page.php and rename it. In the top of the file you place the usual Page Template code as in:

Template Name: Books
get_header(); ?>

Below the normal loop, you then place the code for a new loop:

<?php $loop = new WP_Query( array( 'post_type' => 'books') ); ?>
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

Don't forget to close it with the call for <?php endwhile; ?> at the end.

With this method you can within WordPress add a Page called Books and assign this particular Template to it. This way you can still add general text to the page too and below display the list of all books.

share|improve this answer
Interesting solution-- never would have thought of using pages like that. In my case, this will work just fine :) – Andrew M Jun 19 '11 at 16:10

Your Answer


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.