Have you tried using the WP_Query class? You might find it’s easier to use the built-in tools for this instead of a custom query from scratch. Something similar to the following should work for you:
<?php
$args = array(
'post_type' => 'recipe_cpt',
'tax_query' => array(
array(
'taxonomy' => 'recipe_tx',
'field' => 'term_id',
'terms' => 37
)
)
);
$query = new WP_Query( $args ); ?>
EDIT: note the tax_query
is an array of arrays by design. Many tax query problems are a result of missing this detail.
EDIT: corrected field
value typo above, replacing ‘id’ with ‘term_id’.
Related Posts:
- Looping Through Custom Tax Terms and Displaying All Posts For Each
- How to List Parent Term Links for Custom Taxonomy With & Without Children?
- Print terms with taxonomy and metabox value
- List related terms + taxonomies
- Search Query for Multiple Terms In Same Taxonomy
- How to get the term description in a taxonomy term archive query?
- Query pages by child term
- Adding a query var to taxonomy term archive – gets redirected to the other taxonomy archive page
- add_query_arg to look up page title
- get_posts assigned to a specific custom taxonomy term, and not the term’s children
- How can I get only parent terms?
- Change order of Custom Taxonomy List
- Query users by custom taxonomy and user role
- Determine Term depth
- Custom order of terms for custom taxonomy in admin and website
- Is there a way to disable a term rather than deleting it?
- Best pratice to make taxonomy terms translatable without changing slugs?
- Front End Post Save Child terms
- Taxonomy slug by term ID
- wp_insert_term auto unique name
- wp_get_object_terms – How can I order the resulting array by hierarchy?
- Display Custom Taxonomy Terns ordered by meta_value
- Custom Taxonomy terms with latest post ordered by date pagination issue
- How to set hierarchical terms to a post using wp_set_object_terms
- Echo taxonomy term meta on author.php
- Hierarchical display of custom taxonomy
- Listing child terms of parent term
- Display the taxonomy name of the current term
- Advanced custom fields – taxonomy terms images [closed]
- Automatically assign taxonomy term if custom meta value exists
- List only first-level children of specific custom taxonomy term
- get_terms of post->id
- Dynamically tax_query terms
- get / list categories and counts filtered by custom taxonomy term
- How to get a list of taxonomy terms which are being used only within certain post types?
- WPML Translating a term/taxonomy programmatically
- get_the_terms() to show all custom taxonomies
- Recreating the hierarchy of taxonomies for a dropdown form menu?
- Custom Taxonomy Archive BUG
- Can I limit term selection to one plus parent?
- Insert form checkbox at bottom of taxonomy edit term page
- Exclude Taxonomy Terms from Template Via Back End?
- how does get_term_by know which term to return when the same term appears twice in a hierarchical taxonomy?
- Changing stylesheet depending on custom taxonomy terms
- Taxonomy archive showing no results
- How Can I Change a Taxonomy URL Based On The Originating URL?
- Changing taxonomy term by slug (wp_update_term)
- Custom Taxonomy Term Caching?
- How to show all possible parents and children of a hierarchical taxonomy term?
- A way to query custom taxonomies by name
- Failure to add term meta
- Hierarchical Taxonomy Terms Select Menu Output with selected=”selected” Set
- Rewrite Rules returning wrong data
- WordPress Custom post query sorting does not work
- Weekdays as terms – How to order taxonomy terms by ID in admin panel?
- How to find taxonomy parent id from child taxonomy page?
- Set term on an attachment using wp_set_object_terms and want to display the full term text but it’s showing a slug instead
- How to get_the_term_list() from multiple taxonomies?
- Why does wp_remove_object_terms not work?
- wp_dropdown_categories – how to save in widget?
- how to get term id from current post type instead of name
- echo a specific custom taxonomy term on a different custom taxonomy archive
- Display children category images
- query_posts that have custom taxonomy and limiting what shows based on the taxonomy
- How to show post for a particular term of custom taxonomy?
- Taxonomy archive template that shows posts from more than one taxonomy
- How to get this value inside RETURN
- Hide echo of no categories from get_object_taxonomies
- Custom Taxonomy List with Children
- Displaying Posts Attached to Custom Taxonomy Terms
- Page for custom taxonomy
- How to list terms by first letter, as in A’s then B’s etc
- Cloning product not copying custom taxonomies
- Create new Taxonomy, add extra fields, register terms AND extra fields values?
- get parent and childs from hierarchcial taxonomy
- How to change custom categories term links?
- Get Highest and Lowest get_term_meta() value from Taxonomy Term
- How to get a terms and posts associated with another term?
- Displaying subcategories and then posts in taxonomy template
- WP Query : strange behaviour with multiple no-hierarchical tax
- Print Custom Taxonomy Term Name
- Resize $term attachment using url
- Product dimensions filter by taxonomy
- How can I pull the slug of a custom taxonomy and output it in a class?
- Custom order of taxonomy using wp_get_object_terms and woocommerce_term_meta
- switch statement for taxonomy content
- List terms and order by second word
- Display taxonomy term slugs
- Can I use multi (sub) levels of relation (AND | OR) on custom query?
- Tax query array terms display out of order
- How To Display Selected Terms For Custom Taxonomy?
- displaying links if term is used
- How to include child terms within parent?
- Display term description on hover using get_the_term_list
- stdClass::$labels /wp-includes/general-template.php undefined
- $term->taxonomy stripping out underscores
- Display woocommerce product_cat child terms with thumbnails
- query grandchildren taxonomy terms
- List posts grouped by children of a custom taxonomy
- Hide empty categories on widget