WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type taxonomy loop (3 posts)

  1. slaifer
    Member
    Posted 3 years ago #

    Hello guys, i need to query posts from a specific custom post type and from a specific taxonomy category.

    I've got the following loop

    <?php $folio_loop = new WP_Query( array( 'post_type' => 'portfolio', 'posts_per_page' => get_post_meta($post->ID, 'ep_portfolio_posts_per_page', true), 'orderby' => 'menu_order' ) ); ?>
    
    	 	<?php while ( $folio_loop->have_posts() ) : $folio_loop->the_post(); ?>
    
    	 	<?php endwhile; ?>

    now, i've created a taxonomy named portfolio_categories , and i've created a category (using the taxonomy) with the name "One Column" what should i have to do in order to get posts only from that taxonomy category ?

    Thanks...

  2. Josh Leuze
    Member
    Posted 3 years ago #

    Try adding the taxonomy and term to your query, like this:

    <?php $folio_loop = new WP_Query( array( 'portfolio_categories' => 'one-column', 'post_type' => 'portfolio', 'posts_per_page' => get_post_meta($post->ID, 'ep_portfolio_posts_per_page', true), 'orderby' => 'menu_order' ) ); ?>
    
    	 	<?php while ( $folio_loop->have_posts() ) : $folio_loop->the_post(); ?>
    
    		<?php endwhile; ?>
  3. artsfantasy
    Member
    Posted 2 years ago #

    super! worked beautifully for me!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.