Skip to content

Instantly share code, notes, and snippets.

@tonesfrommars
Created September 30, 2015 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonesfrommars/b639eb483e9838665cdc to your computer and use it in GitHub Desktop.
Save tonesfrommars/b639eb483e9838665cdc to your computer and use it in GitHub Desktop.
$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(
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