Use WP_Query
with a tax_query
and a meta_query
argument, and return only IDs to save a bit of server resource.
$args = array(
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'people',
'field' => 'slug',
'terms' => 'bob',
),
),
'meta_query' => array(
array(
'key' => 'age',
'value' => array( 3, 4 ),
'compare' => 'IN',
),
),
'fields' => 'ids'.
);
$query = new WP_Query( $args );
And check the found_posts
element of $query
— var_dump($query->found_posts);
Related Posts:
- WordPress database error: [Not unique table/alias: ‘wp_postmeta’]
- How much faster is a tax query than a meta query?
- Use custom posts as taxonomy term meta replacement?
- Is it possible to sort the post based on a custom field?
- List Custom Taxonomy Values according to a Post Meta Value
- get_the_terms() to show all custom taxonomies
- Single reusable value for post meta: Custom Taxonomy or Post Meta?
- What is faster: custom taxonomy or serialized post-meta for db retrieval? (over 60,000 posts)
- Is it possible to store Json data in post_meta and manipulate
- Add Custom Taxonomy for Blog Meta Info
- How to separate posts in loop?
- Creating terms vs custom post meta to save data?
- Does using custom taxonomy is more CPU efficient than using meta_data?
- wp_query not resetting, last post hanging
- WooCommerce custom taxonomy as meta?
- Sort taxonomy page alphabetically by meta rather than default post date
- Convert post meta to custom taxonomy?
- Count tags for current post and save into custom meta field (and update it on post edit)
- Is it possible to sort the post based on a custom field?
- Custom post type term names with ampersand in the term name
- Looking for suggestions on creating simple database (Help!!)
- get meta fields and taxonomy of any post type
- Where to put a migration script to switch post information?
- Update fields with post object and custom tax with wp_insert_post
- How can I show custom field according to taxonomy?
- Custom taxonomy with custom meta value is not sorting correctly (query returns the same value for orderby regardless of sort column click)
- Custom taxonomy terms not showing as list Gutenberg Editor
- How to only list the child terms of a taxonomy and not their parents?
- How to use taxonomies on attachments with the new Media Library?
- Using pre_get_posts to rewrite search query to display posts from multiple taxonomies
- How to display custom taxonomies in posts?
- Filtering custom taxonomies
- Hook to process a new taxonomy tag before it is created?
- get_terms() returns an empty array
- Scheduling posts to update once per day with wp_cron
- How to find taxonomy name using only taxonomy TERM ID (or taxonomy term name)
- Multiple users – only allow them to manage their own terms for custom taxonomy when logged in
- How to assign default taxonomy to pages on ‘save_post’?
- Permalinks for quote authors
- How do I display a tag cloud with both post tags AND a custom taxonomy?
- Using a loop to display terms associated with a post
- Custom Taxonomy: Parent still counting deleted Child
- Adding Multiple Values to a Post Meta Key
- In a loop of custom post type, display first custom taxonomy term
- how to create a proper query for getting a list of users with taxonomy related meta key
- Taxonomy page template changing when using query variables
- All posts are still shown when adding category argument to query
- Get direct children of custom taxonomy
- How to add autocomplete to custom taxonomy for CPT
- List subcategory on taxonomy term page
- Operations with custom fields values in a loop
- How to get custom post type taxonomy
- Does WordPress limit the length of slug names for Post Meta or Terms?
- Using wp_list_categories to show more than one custom taxonomy
- Show all posts without a custom taxonomy
- How do I taxonomy terms based on terms they are used alongside?
- How can I populate a select element with terms from a custom taxonomy and filter post results?
- How do I list the pages of a custom taxonomy?
- Why does a new taxonomy term get created when I assign an existing term to a post?
- Add Image Uploader In Admin Panel
- Tell the difference between a term and page when they have the same ID
- How do I create a permalink structure with 2 taxonomies
- How to use multiple archive templates for a taxonomy?
- Pass taxanomy parameters to next_post_link()?
- Clicking Add New button for custom taxonomy only moves element
- How do I return all terms from multiple taxonomies?
- Get all terms, including unchecked, or get the terms outside loop
- get_term_link not working
- Restrict editing of posts with specific taxonomy to users with a matching meta value?
- Show template part if part of term
- Hide terms if they aren’t the same as the current term
- Custom rewrite permalink doesn’t work
- Can you hide empty terms using get_term_children?
- Add file attachments/meta to a custom Taxonomy
- Why can’t I access Custom Taxonomy metadata?
- Permalinks with custom taxonomies and regular categories
- WP_Query tax_query – Show results if child has parent X
- Taxonomy or Custom Field
- Trash Bin for Categories?
- Custom taxonomy – checking if name includes a declared value
- Display just the Post’s parent Category, not child
- Should I use a custom taxonomy or custom post type for grouping a list of panels associated with a group of tests?
- How to add a shortcode function that returns the taxonomy slug of the actual post within the loop
- Random order not working correctly when using default loop + $query->set
- How to get a taxonomy by a term slug?
- Get taxonomy link with post type slug prefix
- Modify title of custom taxonomy archive page
- qtranslate-x problem with custom term description
- WordPress custom taxonomies new/edit post autocomplete
- Custom Tax Archive of Parents Only?
- taxonomy query on front page
- Change taxonomy of posts
- Timetable of Custom Meta Data using Custom Post Type and Custom Taxonomy
- Pagination with custom query (not using posts)
- Taxonomy Parameters in WP Query to get posts from two different taxonomies
- Get Posts with matching lowest taxonomies
- Any way to make custom taxonomy field searchable?
- Select Custom Taxonomy from Theme Options
- Remove Tag Cloud Words from Custom Taxonomy
- Gravity Forms with Advanced Post Creation Add-On not updating ACF fields on custom taxonomy