I want to create proper pages for my post categories, rather than just a default category page. So for example, I'm going to create a Video page and have a load of information about my videos, and then below this info, bring in the loop of posts that appear in the Video category.

So I'm attempting to do the following:

  • Copying my themes page.php and calling it page-categoryname.php and adding a title to the new page template.

  • Finding the loop and limiting the categories that can display in that loop.

Does that sound like the right way to go about it? And how exactly would you edit the loop in the below page code to only display posts from a certain category id?

   <?php get_header(); ?>
<?php while ( have_posts() ): the_post(); ?>

<div class="main group <?php echo wpb_option('general-sidebar','sidebar-right'); ?>">

    <div class="content-part">
        <div class="pad">
            <article id="entry-<?php the_ID(); ?>" <?php post_class('entry group'); ?>>

                <?php get_template_part('partials/page-image'); ?>
                <?php get_template_part('partials/page-title'); ?>

                <div class="text">
                    <?php the_content(); ?>
                    <div class="clear"></div>

            <?php comments_template(); ?>


    <div class="sidebar">   
        <?php get_sidebar(); ?>


<?php endwhile; ?>
<?php get_footer(); ?>

Any help would be great.


  • Why don’t you just customize the category archive? You can get very creative here. – fuxia Apr 30 '13 at 19:41
  • Please see the Template Hierarchy. You could/should do this by means of the category-{slug}.php file, I guess. – tfrommen Apr 30 '13 at 19:42
  • But if I'm adding specific content to the page before my category loop starts, wouldn't it be easier to add that content using the Page editor of Wordpress, rather than hard coding it all? – EILrichard May 1 '13 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.