• Hi there,

    I have created a custom post type (named project) and a custom taxonomy (named work) to group these projects by medium – 3d design, graphic design, etc.

    On my portfolio index I am trying to get it to list the 3 most recent posts from each custom taxonomy term. Eg. 3 posts from 3d design, 3 posts from graphic design and so on.

    Is there any way I can do this without having to hard-code the terms in?

    So far I use this loop to query all posts from all ‘work’ taxonomy:

    <?php
    				$loop = new WP_Query( array(
    				'post_type' => 'project',
    				'taxonomy' => 'work',
    				'term' => '',
    				'posts_per_page' => 9
    				) );
    				$postcount = 1;
    				$row = 1;
    
    				while ( $loop->have_posts() ) :  $loop->the_post();
    				echo '<div class="project row-' . $row;
    				if ( $postcount == 1 ) { echo ' first'; }
    				echo '">';
    				if ( $postcount == 3 ) { $row++; $postcount = 0; }
    				$postcount++;
    				?>
    
    				<?php
    					if ( has_post_thumbnail() ) : ?>
    					<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
    					<?php the_post_thumbnail('project-thumb'); ?>
    					</a>
    					<?php endif; ?>
    				<?php the_title( '<h2 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h2>' ); ?>
    
    					<div class="entry-content">	
    
    						<?php the_excerpt(); ?>
    					</div>
    					</div>
    				<?php endwhile;

    Appreciate any help.. I am trying, but I feel this is above me and I’m not sure where to start.

  • The topic ‘List 3 most recent posts from a custom category taxonomy ?’ is closed to new replies.