Category-specific sidebar
-
This will hopefully be simple — in the sidebar of each single-post page, I want a box which says, “More from this category” and lists the last 5 relevant headlines from whatever category you’re in. I realize I can specify an ID and do it like this:
<?php if ( is_single() || in_category('3') ) : ?> <li> <h2>More in this Section</h2> <ul class="bullets"> <?php $posts = get_posts('numberposts=10&category=3'); foreach($posts as $post) : ?> <li> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </li> <?php endforeach; ?> </ul> </li> <?php endif ; ?>
But, I don’t want to manually type in the ID# for each. How can I use the code above and make it more dynamic?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Category-specific sidebar’ is closed to new replies.