Skip to content

Instantly share code, notes, and snippets.

@solid-pixel
Created January 6, 2017 14:32
Show Gist options
  • Save solid-pixel/93ffe0f0418f292412f83c19565990bd to your computer and use it in GitHub Desktop.
Save solid-pixel/93ffe0f0418f292412f83c19565990bd to your computer and use it in GitHub Desktop.
Grab Custom Posts from specific Taxonomy
<ul>
<?php
$query = new WP_Query( array(
'post_type' => 'course', //post type slug
'tax_query' => array(
array(
'taxonomy' => 'course_type', //taxonomy slug
'field' => 'slug',
'terms' => 'post-graduate') //term slug
)) );
if ( $query->have_posts() ) : ?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; wp_reset_postdata(); ?>
<?php endif; ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment