Skip to content

Instantly share code, notes, and snippets.

@mattboon
Created October 10, 2011 12:32
Show Gist options
  • Save mattboon/1275191 to your computer and use it in GitHub Desktop.
Save mattboon/1275191 to your computer and use it in GitHub Desktop.
WordPress - Query Custom Post Type and taxonomy term by ID
<?php
// gets the ID from a custom field to show posts on a specific page
$buildType = get_post_meta($post->ID, 'build_type_id', true);
// run query
query_posts(array(
'post_type' => 'portfolio',
'showposts' => -1,
'tax_query' => array(
array(
'taxonomy' => 'build-type',
'terms' => $buildType,
'field' => 'term_id',
)
),
'orderby' => 'title',
'order' => 'ASC' )
);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment