Trouble listing posts in a taxonomy
-
I have posts which are identified by an artist cpt-onomy. I want to be able go to each artist’s cpt-onomy and see a post listing of all posts tagged to this artist. I’ve tried many different queries, but I haven’t been able to get any of them to return any posts.
Here is my current query:
<?php global $post; $current_artist = get_query_var('artist'); $current_artist_id = get_the_ID(); echo $current_artist; echo $current_artist_id; $args = array( 'numberposts' => -1, // we want to retrieve all of the posts 'post_type' => 'post', 'tax_query' => array( array( 'taxonomy' => 'artist', 'field' => 'slug', 'terms' => '$current_artist', 'operator' => 'IN' ), ), 'suppress_filters' => false, // this argument is required for CPT-onomies ); ?> <ul> <?php $custom_posts = get_posts($args); foreach($custom_posts as $post) : setup_postdata($post); ?> <li><a href="<?php echo get_permalink( $post->ID ) ?>" title="<?php echo get_the_title( $post->ID ); ?>"><?php echo get_the_title( $post->ID ); ?></a></li></ul> <?php endforeach; ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Trouble listing posts in a taxonomy’ is closed to new replies.