Dynamic Sub-Category
-
I have several parent categories each having 2 or 3 child or subcategories. I am attempting to post 3 articles on a ‘Category’ page.
I need the subcategory template that I am using to call Article 1 to id=contentsingle Article 2 to id=subcontent-top and Article 3 to id=subcontent-bottom depending on what category you are in.
I am able to get it working using the below code and it does exactly what I want. Expcept that I instead of a static template (
cat=3
) I want that to be dynamic. If this could be resolved it would be great.<?php /* Template Name: Subpage */ ?> <?php get_header(); ?> <?php get_sidebar(); ?> <div id="content"> <div id="content-single"> <?php query_posts('cat=3&showposts=1'); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <h4><?php the_title(); ?></h4> <div class="entry"> <?php the_content('<p>Read the rest of this page »</p>'); ?> <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> </div> </div> <?php endwhile; endif; ?> <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?> </div> </div> <div id="subcontent"> <div id="subcontent-top"> <?php query_posts('cat=3&showposts=1&offset=1'); ?> <?php if (have_posts()) : while (have_posts()) : the_post('showposts=1&offset=1'); ?> <div class="post" id="post-<?php the_ID(); ?>"> <h4><?php the_title(); ?></h4> <div class="entry"> <?php the_content('<p>Read the rest of this page »</p>'); ?> <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> </div> </div> <?php endwhile; endif; ?> <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?> </div> <div id="subcontent-bottom"> <?php query_posts('cat=3&showposts=1&offset=2'); ?> <?php if (have_posts()) : while (have_posts()) : the_post('showposts=1&offset=2'); ?> <div class="post" id="post-<?php the_ID(); ?>"> <h4><?php the_title(); ?></h4> <div class="entry"> <?php the_content('<p>Read the rest of this page »</p>'); ?> <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> </div> </div> <?php endwhile; endif; ?> <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?> </div> </div> <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Dynamic Sub-Category’ is closed to new replies.