Support » Plugins » Hacks » Display 1 post (with a custom Taxonomy) from each category

  • I have hit a wall with this one and I can’t seem to figure it out…I’m starting to lose hope!
    I could really use some help on this one.

    Here is what I’m trying to do:
    I’m trying to display 1 post from each category, but only if that post has a certain custom taxonomy.

    For example…

    I’d like to display a post called “Come Together” in the category “Beatles”. BUT I only want that post to display IF it has the custom taxonomy labeled “Abbey Road”

    And I’d like it limited to only one post per category.

    I believe this is possible, I just can’t seem to make it work right.

    Some help would be really, really appreciated.


    Here is my code (which is not working)

    foreach($categories as $category) {
    $taxonomy = 'session';
    $param_type = 'session';
    $include_terms = 21; //term ids to include
    'showposts' => 1, // you can fetch number of articles from each category
    'category__in' => array($category->term_id),
    'include' => $include_terms,
    if ($posts) {
    foreach($posts as $post) {
    setup_postdata($post); ?>
    <div class="twentyten-artist-post">
    	<div class="twentyten-artist-post-image">
    		<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_post_thumbnail(array(20,20), array ('class' => 'alignleft')); ?>
    	<br><div class="twentyten-artist-post-title">
    		$category = get_the_category();
    		echo $category[0]->cat_name;
    		$category = get_the_category();
    		echo "(", $category[0]->category_count, ")";
    	<div class="clear"></div>
     } // foreach($posts
     } // if ($posts
     } // foreach($categories

  • The topic ‘Display 1 post (with a custom Taxonomy) from each category’ is closed to new replies.