Reputation: 583
Seen a lot of posts elsewhere, but nothing quite hitting the mark.
I need to echo the description of a specific term of a custom taxonomy related to a custom post type.
Right now, I'm doing the following loop successfully to pull content for related custom posts per term (in this case my custom post type is 'rental_gear' and my term is 'cameras':
<? $args = array(
'post_type'=> 'rental_gear',
'type' => 'cameras',
'order' => 'ASC'
);
$the_query = new WP_Query( $args );
if($the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
?>
<li><a href="<? the_permalink(); ?>">› <? the_title(); ?></a></li>
<?php endwhile; endif; wp_reset_postdata(); ?>
Can I pull the term's description in this loop? I've tried the 'get_term' function and pulling '$term->description;' but those are related to the post, and this is on an overview page listing information from many posts (hence the use of the loop)
Upvotes: 0
Views: 1179
Reputation: 1375
You didn't mention the name of your custom taxonomy, so replace your-taxonomy
. This will query ALL rental_gear
posts that have the camera
term in your-taxonomy
.
<?php
$args = array(
'post_type' => 'rental_gear',
'tax_query' => array(
array(
'taxonomy' => 'your-taxonomy',
'field' => 'slug',
'terms' => 'camera'
)
)
);
$query = new WP_Query( $args );
Upvotes: 1