-
-
Save jeweltheme/0b60a01c09c0fbc9318fb776b7c1a2ed to your computer and use it in GitHub Desktop.
WordPress - Query Custom Post Type and taxonomy term by ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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