Coding help for multiple child categories calling custom sidebar
-
Thanks to this topic I have a custom sidebar called when a post is from a single parent category. The parent category page also calls the custom sidebar from outside the Loop like this:
<div> <?php global $post; $side = false; foreach( (get_the_category($post->ID)) as $category) { if ($category->cat_ID == 99) {$side = true;}; } if($side) { include(TEMPLATEPATH."/sidebar-custom.php"); } else { include(TEMPLATEPATH."/sidebar.php"); } ?> </div>
The parent category page is called from a custom template because I need the posts in the parent category to display in ASC order. For that, just before the Loop, I’m using:
global $wp_query; query_posts( array_merge( array('cat' => 99, 'order' => ASC), $wp_query->query ) );
Now, I’m trying to get that parent category’s child categories to both call the custom sidebar and to display posts on child category pages in ASC order, as well.
There are upwards of 50 child categories under the parent category, and I’m looking for a way to get each of the child category pages to display both the custom sidebar and their posts in ASC order without having to create upwards of 50 custom category templates.
Is this possible to do with elseif statements and/or parameter arrays in the custom template for the parent category?
Thanks very much.
- The topic ‘Coding help for multiple child categories calling custom sidebar’ is closed to new replies.