tags:

views:

29

answers:

4

I have some custom post types, such as 'review'. I can't seem to find out how to make a section (e.g., www.mysite.com/reviews/) which works like the blog home page, but lists reviews instead of posts (with pagination and everything). I'd like to use a separate template for it too.

A: 

You need help getting .htaccess to convert your categories into hard URLs. I thought WP did this automatically so you'll want to look and make sure you have set up the directory permissions on WP so it can write to your .htaccess file.

Please read this guide and it will be cleared up.

Geekster
Well, the URL rewriting isn't the problem. The question is how do I create the page itself?
Scott
You don't create that page. By setting a category, anything tagged with the same category would be listed there. Now if you want a static page you just add a new page instead of a new post.
Geekster
It's not a category though, it's a custom post type.
Scott
Why bother doing a custom post type? I don't see the payoff. Posts can have categories too I think. Are you confusing the term "post" with the term "page"?
Geekster
A: 

Create a page called reviews and then create a new template in your theme folder called page-reviews.php. Add all the necessary elements to the template and include a query_posts in front of your post loop. It should look like this:

<?php query_posts("post_type=reviews"); ?>
    <?php if (have_posts()) :?>
    <?php while (have_posts()) : the_post(); ?>        
        <div class="post" >
            <h2><a href="<?php the_permalink() ?>" ><?php the_title(); ?></a></h2>                     
            <?php the_content(); ?>     
        </div><!-- Post ends -->
    <?php endwhile; ?>
    <?php else: ?>
    <p>Sorry, we could not find what you were looking for</p>
    <?php endif; wp_reset_query(); ?>
Colin Morgan
A: 

Duplicate the file in your theme called "single.php" and rename it to "single-reviews.php"

Since "single.php" is used for your regular posts, you can append the name of the custom post type to the end of "single-" to automatically use that.

Now once inside of the file "single-reviews.php" you can adjust the layout to be how ever you want.

If you get a 404 error, or it is not showing you the correct layout, you may need to flush the rewrite rules. You can do this two ways.

  1. Go to the permalinks page in your backend and it will sometimes auto flush them.

  2. The best way to do it is in your "functions.php" file in your theme directory add the following code:

    add_action ( 'init', 'flush_rewrite_rules' );

    function flush_rewrite_rules() { global $wp_rewrite; $wp_rewrite->flush_rules(); }

Will Ayers
A: 

Create a new page called reviews. Create a new page template that calls the custom post type. Assign the page template to the page...

philmadelphia