If it’s not too much of work, you could switch from using meta data to custom (private) terms for tagging the tickets to agents.
So when ever an agent (user) is created, you would have custom function run that executes wp_insert_term
to create an agent-term
, where the newly created user ID
is used as the term slug
. You would then use wp_set_object_terms
to attach the agent-term to the ticket posts. And when using wp_set_object_terms
you need to make sure agent/user ID is passed as string
as the functions $terms
parameter. If you try passing the user ID as int
WP will interpret it is a term ID
and setting the terms would fail.
By using agent-terms you could avoid using meta_query
and do everything with tax_query
.
Related Posts:
- WP_query – Filter by tax_query and meta_query using multiple select
- The Operator “NOT IN” Does Not Work In tax_query
- Sorting a list of posts displayed under a list of associated terms (which should be sorted without initial articles)
- Combine tax_query and meta_query in WP_Query
- Query for custom post type objects in a taxonomy and with a meta value
- wp_query check if integer exists in custom field’s array
- Why is this query not working? (Standard posts + custom post type)
- How to display Related Posts based on number of taxonomy terms matched
- tax_query not working in template
- WP_Query parameter conflict
- Custom Category Walker with Image, Fallback to Most Recent Post in Category Image
- tax_query (if the terms are empty)
- custom post type and a “sticky” position taxonomy
- How to search through all child taxonomies using WP_Query?
- WP Query tax_query not returning posts
- Not able to get my custom search result using meta_query and tax_query together?
- tax_query showing no results
- Display all posts in a custom post type, grouped by a custom taxonomy
- Exclude a category from WP_Query
- WP_Query() show posts that end later than today
- WP_Query orderby custom field then post_date in one query
- query multiple taxonomies
- Custom Taxonomy with Custom Post Type Finds No Posts
- Custom query – alternate posts by category
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- search query within custom taxonomy term, post title and meta field
- how to group custom post type posts by custom taxonomy terms
- Sort the main query in subcategories/terms?
- Can’t sort order of wp_query with 2 meta keys
- Comparing timestamps in meta query doesn’t work
- Display two post types ordered by two custom fields
- Want to filter only parent post in admin area
- Multiple Archive Pages for Custom Post Types AND Taxonomies
- Exclude current post when getting related post on custom post type and taxonomy
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Ordering Custom Post Types with WP_Query
- How loop through posts based on custom fields
- Filter posts with meta_query NOT IN where value has multiple values
- Querying CPT with Two Taxonomies
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Custom Query to display posts with custom field
- Get taxonomy description based on variable
- Displaying Metabox value (custom post type taxonomy)
- Querying Term Posts in Loop
- Group custom posts by custom taxonomy names
- How can i skip same post from taxonomy term?
- Filter by custom taxonomy slug on a custom post type
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Pagination : How to remove /page/x/ after a ‘POST’ action on a form returning to page 1
- Query custom post type by category slug
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Archive for custom taxonomy lists all posts instead of current taxonomy
- Wrong request query on cpt and tax
- Search / Filter posts on Title/Content OR Tags
- WP_Query most viewed posts, in multiple Post Types, last 30 days, excluding a specific taxonomy term
- Custom-Posttype & Custom Taxonomy WP_Query
- How to Filter custom post type by taxonomy?
- Stuck in Order by more then one
- WordPress loop: Show only a Custom Post Type Taxononmy TERM
- What’s the WP way to load remaining custom posts?
- Custom Widget WP_Query problem
- Query Custom Post Type Taxonomy term with multiple parameters
- Query based on custom fields start and end date
- Retrieve custom post types by custom taxonomies with WP_Query
- Using page slug in wp_query
- Custom taxonomy wp_query woes.
- Different options per post type in WP_Query
- How to show all taxonomies within custom post type loop
- Exclude latest post from WP_Query taxonomy term loop
- How to query Posts from a custom post type which contains a custom taxonomy?
- Query Posts that have Custom Taxonomy
- Query Posts, order by meta value
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- Display featured posts for a custom post type by taxonomy
- What is the most efficient way to execute recursive complex queries?
- “Menu order” being ignored when querying posts from a parent taxonomy with “include_children” set to true
- Custom Query: Multiple CPTs and a taxonomy filter
- custom taxonomy pagination 404 error
- have to do a while have post to show for two custom post types sharing the same taxonomy?
- Dynamic template page calling shared taxonomies CPT or Plugin post type : how to clone taxonomy for plugin + set up dynamic shortcode
- display post count in archive page that have relation with another taxonomy term
- Use WP_query to match post types based on custom field values
- WP_Query for custom taxonomies showing posts from non-specified terms?
- Query a custom taxonomy in a function to create an csv file
- Custom search for a custom post type in WordPress
- tax_query not working?
- Meta_Query refuses to return results
- Displaying WordPress posts from post and custom post type in custom taxonomy
- Query events post type after current date and timezone
- Get posts of an specific term of a custom taxonomy
- Conditional posts in WP_query for search
- Checking Taxonomy Terms for a Custom Post Type With get_the_terms Not Working
- Get posts associated with custom taxonomy alternate way
- Loop with Custom Post Type and Taxonomies
- How to display elements of different post types?
- Catergory args causing loop not to show
- Using tax_query to get single post per category
- Attaching multiple custom taxonomies to one CPT?
- Get X posts with the same terms as the current post (custom post type and custom taxonomy)
- WP Query – Can’t get posts with specific taxonomy