0

Hey i was wondering how could i show post from a certain taxonomy term in the loop.

 <?php the_excerpt(); ?>

I have a taxonomy entitled "series" under my post type entitled "Gallery", and in "series" i have the TERM "pretty-little-liars". Under my post type "pretty-litte-liars" archive it shows all the post posted in that CPT. I would like to add a code that also allows post posted under the taxonomy "series" with the term "pretty-little-liars" to show on that page as well.

what do i add to the above excerpt code to make this happen?

1 Answer 1

1

Try this.

$type = 'buehne';  // Name of the Custom Post Types
$tag =  'TagName';


$args =  array(
        'post_type' => $type, 
        'paged' => $paged,
        'posts_per_page' => -1, 
        'orderby' => 'menu_order',
        'order' => 'ASC', 
                'tax_query'=>array(
                    array(
            'taxonomy'=>'th3', //name of the Taxonom 
            'field'=>'slug',
            'terms'=>array($tag)
                            ))
                    );



$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
    if(is_object_in_term($post->ID,'th3','TagName')) {  
        the_title(); ";

    }
endwhile;
2
  • this looks complicated, where do i add this Commented Aug 21, 2012 at 15:42
  • You have to Query a new loop with the Parameters you like to output. Place this code in your Template. with the Line is_object_in_term() you can filter the output you want. You could search in the codex page for custom post types and for is_object_in_term Commented Aug 21, 2012 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.