Displaying particular category for a child page in a single template
-
I have a single template that has if/elseif functions to display slightly different layout for certain pages. Here’s what the code in the template looks like right now:
<?php if (is_page('scholarship-program')) { ?> <div class="clear"></div> <div id="content_bg"> <div id="content_wrap"> <div id="content"> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; ?> </div> <!--end content--> <?php include ('sidebar-custom.php'); ?> <div class="clear"></div> </div> <!--end content wrap--> </div> <!--end content bg--> <?php } elseif (is_page('our-blog-comments')) { ?> <div id="content_wrap"> <?php query_posts('category_name=main'); while (have_posts()) : the_post(); the_content(); endwhile; ?> </div> <!--end content--> <?php } else { ?> <div id="content_wrap"> <div id="content"> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; ?> </div> <!--end content--> <?php include ('sidebar-custom.php'); ?> <div class="clear"></div> </div> <!--end wrapper content--> <?php } ?>
The problem I’m having is the “our-blog-comments” page. It’s a child page that I ideally want to display just one category called “Main.” I’m pulling my hair over this because it doesn’t filter out other categories and can’t get this to work! What am I missing?
Thanks in advance.
- The topic ‘Displaying particular category for a child page in a single template’ is closed to new replies.