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 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>
                </div>          
            </article>

            <?php comments_template(); ?>

        </div><!--/.pad-->
    </div><!--/.content-part-->

    <div class="sidebar">   
        <?php get_sidebar(); ?>
    </div><!--/.sidebar-->

</div><!--/.main-->

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

Any help would be great.

R

share|improve this question
    
Why don’t you just customize the category archive? You can get very creative here. –  toscho 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. –  t f 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? –  user2185625 May 1 '13 at 8:22
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.