“More from this Category”, excluding current post
-
In the sidebar of the the Mimbo theme, there is a module called “More from this Category”. The relevant code is:
<?php if ( is_single() ) : global $post; $categories = get_the_category(); foreach ($categories as $category) : ?> <li><h2>More from this category</h2> <ul class="bullets"> <?php $posts = get_posts('numberposts=10&category='. $category->term_id); foreach($posts as $post) : ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
Anyway, I’m building a similar module for my new theme, but unlike Mimbo, I want to exclude the current post from the list so there’s no redundancy. Any simple way to do that?
- The topic ‘“More from this Category”, excluding current post’ is closed to new replies.