Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
$slugs = array('overview', 'advertising', 'bacon');
foreach ($slugs as $slug) {
$ids = get_posts( array(
'post_type' => 'attachment',
'post_status' => 'any',
'posts_per_page' => -1,
'tax_query' => array(
'taxonomy' => 'media_category',
'field' => 'slug',
'terms' => array($slug),
'fields' => 'ids', // only return IDs
echo "SLUG" . $term_slug; echo "IDs"; var_dump($ids);
//first var_dump() always returns empty, even when slug doesn't change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment