Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
get posts with any term within a taxonomy
<?php
$type = 'my-post-type';
$tax = 'my-taxonomy';
$args = array(
'post_type' => $type,
'nopaging' => true,
'tax_query' => array(
array(
'taxonomy' => $tax,
'field' => 'term_id',
'terms' => array_values( get_terms( $tax, array( 'fields' => 'ids' ) ) ),
),
),
);
$items = get_posts( $args );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment