What you need is to add a tax_query
to your WP_Query
arguments, where you check that your taxonomy exists on the posts you are querying.
Here is an example that fetches the 3 latest published posts that have the taxonomy site set.
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 3,
'tax_query' => array(
array(
'taxonomy' => 'site',
'operator' => 'EXISTS',
),
),
);
$the_query = new WP_Query( $args );
Good reads
- Documentation for WP_Meta_Query
- Documentation for WP_Query
Related Posts:
- Check if a post has any term in this custom taxonomy?
- Contact Form 7 – Populate Select List With Taxonomy [closed]
- Why is my working Custom Taxonomy not in get_taxonomies array?
- Custom taxonomy hide meta box but show in menu
- display posts with same taxonomy term
- Is there a way to disable a term rather than deleting it?
- How do I filter posts by taxomony using AJAX
- SQL QUERY needed to get POST category (taxonomy) ? – MUST be SQL statement
- Remove Category description textarea
- Create taxonomy with meta term using the WP Rest Api
- How can I set up a category “overview” page?
- Sort posts by number of matched terms
- Possible to register multiple custom taxonomies in one function?
- Taxonomies not appearing in columns on dashboard
- Echo taxonomy term meta on author.php
- Hierarchical display of custom taxonomy
- How to output the taxonomy term name in a widget
- List taxonomy / category count showing list published posts only
- Advanced Tax Query
- Save Filter for Taxonomies
- Function to limit the number of posts in taxonomy.php
- Is It Possible To Have Shared WordPress Custom Post Types?
- WordPress renames slug of tags used in multiple taxonomies?
- User role permissions based on taxonomies
- WP Query with custom taxonomy
- How to prevent posts duplicating when viewing a custom taxonomy term
- get_the_terms() to show all custom taxonomies
- Custom taxonomies making WP very slow – Way to fix?
- Get Taxonmy Term ID For Current Post
- meta_key & meta_value not working with get_pages and custom taxonomy
- Is it possible to create exclusive custom taxonomy?
- wp_insert_post not updating custom taxonomy selected if logged in as a subscriber
- Changing stylesheet depending on custom taxonomy terms
- Taxonomy with_front causes all
- Taxonomy archive showing no results
- Autogenerate Front End Form Field With jQuery
- Changing taxonomy term by slug (wp_update_term)
- Taxonomy template shows only 10 posts
- Rewrite Rule Working for all but one of the taxonomies created
- Get taxonomy based on another taxonomy slug
- Extend & Search Native WordPress Image Galleries With Tags and Taxonomies?
- How to Rewrite Taxonomy URL to Include the Post Type as the Second Segment of the URL?
- How to get all taxonomies which can be added in menu?
- WordPress Tag or Custom Taxonomy Return All Posts if has that Word in Post Title
- woocommerce custom product category template
- Custom Taxonomy index/archive hierarchy
- Filter custom taxonomy archive posts by 2nd custom taxonomy using select dropdown
- How to show all post related taxonomies
- Multi-select field for Taxonomy can’t save the value
- How to create a custom taxonomy using a shortcode?
- Get the taxonomy of the post
- How Parent Taxonomy automatically added to the post when using `wp_set_object_terms()`?
- Get object for a few selected taxonomies
- Get only immediate children (and not grandchildren) of a hierarchical custom taxonomy term
- How to group all terms children’s in custom taxonomy?
- Loop through custom taxanomy in post and display custom fields from posts
- query_posts that have custom taxonomy and limiting what shows based on the taxonomy
- Dropdown taxonomy lists in admin menu
- Custom Taxonomy Not Saving in Front End Post
- Taxonomy archive template that shows posts from more than one taxonomy
- How to get the term description in a taxonomy term archive query?
- How to define %category% for custom taxonomies?
- Set two terms for a post when they differ only by an accent
- Rewrite Search URL Permalink For CPT Custom Taxonomies
- Custom field with terms from another taxonomy programmatically
- Taxonomies and subtaxonomies relations
- Listing Cities A custom taxonmy by selection order
- Template taxonomy-{taxonomy}.php doesn’t show my posts
- Unregistered taxonomy apears still as emtpy filter list
- Get Highest and Lowest get_term_meta() value from Taxonomy Term
- Custom Taxonomy Not Being Recognized by is_tax()
- Ignore punctuation marks in taxonomy order by name
- How to truncate the description in the admin panel for a custom taxonomy
- What’s the url queryvar for a taxnomy archive?
- set_object_terms for custom taxonomy in custom post type – not working
- Get all users attached to a taxonomy
- Resize $term attachment using url
- Custom taxonomy escaping html attr
- Showing list of custom posts of a custom taxonomy
- Show portfolio category slug in url ( if exist)
- switch statement for taxonomy content
- Add image to taxonomy and output to homepage
- How do you search for a post by custom taxonomy?
- Index page of posts tagged with two separate taxonomies
- Child Pages and Custom Taxonomies
- Remove taxonomy menu without removing the metabox?
- create taxonomy
- Select default taxonomy on dropdown
- WordPress Taxonomy Menu
- What is the current page’s Taxonomy?
- Loop custom post type by taxonomy (Category)
- get_terms() – unexpected ‘=>’ (T_DOUBLE_ARROW) error
- get_term_children specific no id
- query grandchildren taxonomy terms
- Prevent random entries in hierarchical false taxonomies
- Exporting CSV of users with custom user taxonomies out of WordPress
- Taxonomies starting with a hyphen (minus) to assign B.C. dates to a post
- Querying posts globally based on custom taxonomy with its own taxonomymeta table
- How to delete unused terms?
- Child terms with improper parent in the url should redirect to 404