You should not use a direct SQL query, instead try the WP_Query
tax queries e.g.:
$args = array(
'post_type' => 'post',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'category',
'field' => 'id',
'terms' => array( 22 )
),
array(
'taxonomy' => 'job',
'field' => 'name',
'terms' => $terms,
'operator' => 'IN'
)
)
);
$query = new WP_Query( $args );
Where $terms is an array of term names.
Related Posts:
- how to access the $query variable inside taxonomy-xxx.php template file?
- “tax_query” parameter not working with WP_Query
- Can’t get a custom template taxonomy page to display
- Custom Taxonomy and Tax_Query
- Custom Taxonomy Archive Page
- pre_get_posts with tax_query causes empty result
- Including all terms in wordpress tax_query
- Taxonomy Templates… by hierarchical level?
- How to display a listing template of a certain taxonomy?
- How to use wp_terms_checklist() on front end
- Using tax_query creates a 1 = 0 or 1 = 1 in $wp_query->request
- Custom taxonomies, with custom rewrites/slug, AND loading a taxonomy archive template from a plugin
- Custom Taxonomy Template not respecting ‘include_children’ => ‘false’
- How can I set up a category “overview” page?
- search query within custom taxonomy term, post title and meta field
- Which template name to use for taxonomies but not their terms?
- Sorting a list of posts displayed under a list of associated terms (which should be sorted without initial articles)
- On Taxonomy Template page, want to add Post_Type
- tax_query not working on main query
- Make Custom Taxonomy Category Use Parent Template
- Ordering Posts with Custom Taxonomy Terms Array
- Custom taxonomy template not working
- List taxonomy / category count showing list published posts only
- Using a different template per Custom Taxonomies for single term archive pages
- why do drafts return as part of wp_query?
- Improving WP_Query performance for multiple taxonomies
- Dynamically tax_query terms
- Woocommerce custom taxonomies page
- How to output content based on same custom taxonomy?
- Generic taxonomy-term template page
- How do I sort posts by custom taxonomy?
- pre_get_posts Tax Query not working for custom author page
- 404 for a custom taxonomy?
- Get pages only with a specific taxonomy
- How to add autocomplete to custom taxonomy for CPT
- Custom taxonomy query not working with switch_to_blog
- Why is my taxonomy template not shown?
- ‘wp’ action hook not firing in admin and login?
- Taxonomy archive showing no results
- Get taxonomy parent using child slug (from merged taxonomies)
- Meta description – template code to get category description
- Create and set templates for custom taxonomies
- Pagination on custom taxonomy
- How to have two different versions of a tag/category/taxonomy archive page?
- How do I create a custom archive page depending on the custom taxonomy type?
- Manipulate WP Query using a custom post type and multiple tax_query taxonomies
- Retrieve Custom Taxonomies according to posts selected
- Custom Taxonomy Not Working When added to WordPress Search
- Different single page templates for taxonomies
- Hiding taxonomies with no children WP_Query & tax_query
- WordPress Custom post query sorting does not work
- Override Taxonomy Template
- Set tax_query conditionally with new WP_Query
- Taxonomy Parent Name
- Avoid taxonomy-%term%.php if more than one taxonomy
- Update table wp_term_taxonomy.count after INSERT INTO via SQL
- tax_query not working
- Returning One custom taxonomy term name
- Make child taxonomy categories use a set template
- How can I make front page to display custom taxonomy page?
- Why get_page_template() doesn’t show taxonomy template file name?
- How to do a particular wp_query taxonomy search
- tax_query: Don’t show posts with parent term when they have a corresponding child term applied
- Build filter for post-type + multi taxonomies + multi terms
- Create alphabetical Pagination for custom taxonomy?
- pagination not working on custom-taxonomy template
- Custom arguments in WP_Query
- How to add custom content to custom taxonomy
- WP_Query tax_query – Show results if child has parent X
- how to use tax_query to apply both terms or one if one is empty
- Template file renders on local install, not on web
- Catch all taxonomy template
- Taxonomy archive uses incorrect template when query strings are used
- Get Posts Related to Category By category id or slug
- Unknown column ‘wp_posts.ID’ in ‘field list
- Display just the Post’s parent Category, not child
- How to use custom slug and custom templates for custom taxonomy?
- Tax-query on taxonomy doesn´t work
- how do you pull data from two taxonomies?
- How to get a terms and posts associated with another term?
- Custom taxonomy archive template not recognised
- WordPress Multiple Taxonomy Query
- Post not showing in my custom advanced search
- How to display custom taxonomy
- WordPress hiding posts without content on custom taxonomy query. How to solve?
- How to use tax_query other than by slug or id or solve custom taxonomy tags conflicts with pre-existing tags?
- Tax query array terms display out of order
- WordPress doesn’t respect the template hierarchy?
- Advanced AND tax_query in sidebar with 2 taxonomies
- Advanced search: roles and multiple taxonomies
- How to limit posts to 1 from each term with tax_query?
- Can you orderby slug in a taxonomy archive page using WP_Query?
- Custom Taxonomy Template Variables Available?
- wp_get_object_terms count on taxonomies within an category archive
- is_tax not working for custom taxonomy
- Complex Taxonomy scheme
- Custom Taxonomy Query
- Include get_term_link inside search
- Sorting Custom Taxonomy in ASC/DESC order?
- add_rewrite_rule pagination 404 error on page 4 and above