WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Show similar children of a category (1 post)

  1. Lars M
    Member
    Posted 5 years ago #

    I'm trying to modify this code to show only the similar children categories assigned
    to a single post. What can I do to this code, so that it excludes the parent category, but includes the children?

    <?php if (is_single()) {
    	if (get_the_category()) {
    ?>
    		<p>These similar posts from the same categories may be of interest to you:</p>
    <?php
    		foreach((get_the_category()) as $category) {
    			echo '<h3>Related Posts in '.$category->cat_name.'</h3>'."<ul>";
    			query_posts('cat='.$category->cat_ID.'&limit=10');
    			while (have_posts()) {
    				the_post();
    ?>
    				<li><a href="<?php the_permalink() ?>" title="permalink to <?php the_title() ?>"><?php the_title() ?></a></li>
    <?php
    			}
    			echo "</ul>";
    		}
    	}
    }?>

    Any help much appreciated!

Topic Closed

This topic has been closed to new replies.

About this Topic