WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Display all posts in a specific category (3 posts)

  1. ericakadisco
    Member
    Posted 7 years ago #

    This seems easy but for some reason I can't figure it out.

    I am trying to create a template page that shows only posts from a specific category. I would like to display the full posts, not just the titles of the posts.

    The page is called Reviews and will have all posts in the category Reviews, which is category ID 8.

    This is the code I have so far. It shows the header but does not display any posts.

    <?php
    /*
    Template Name: Reviews
    */
    ?>
    <?php get_header(); ?>
    <div id="content" class="narrowcolumn">
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <h2><?php the_title(); ?></h2>
    <div class="entry">
    <?php the_content('<p class="serif">Read the rest of this page &raquo;
    '); ?>
    <?php link_pages('<strong>Pages:</strong> ', '
    ', 'number'); ?>
    </div>
    </div>
    <?php endwhile; endif; ?>
    <?php edit_post_link('Edit this entry.', '', '
    '); ?>
    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Thanks!

  2. Michael Bishop

    Posted 7 years ago #

    You need to create a category specific template, not a Page.

    Category_Templates

  3. ericakadisco
    Member
    Posted 7 years ago #

    Ah, okay. I see. I created a file called it Category-8.php and uploaded it to my blog root. Then in my header I linked the page 'Reviews' to go to the page

    <a href="?cat=8">Reviews</a>

    In my header. And now I can just mess around with the Category-8.php to make it look how I want.

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags