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
- WP_Query not using relation key as expected and not producing any results
- WP Query filtering by custom category not showing all relevant posts
- WP_Query order custom post type with certain meta key value by post modified date
- Cant’ Display Custom Post Type Title Base on Tax Terms
- Query custom posts from custom taxonomy
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- Query Custom Post Type by Taxonomy
- Display featured posts for a custom post type by taxonomy
- Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- Related “custom post type” using “custom taxonomy”
- What is the most efficient way to execute recursive complex queries?
- Sorting the Loop by Taxonomy Value
- “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
- How to order query results based on if a custom field has been populated, then the order by the date of the post?
- custom taxonomy pagination 404 error
- Ordering by meta value not working
- set object terms after some some time of published post – functions.php
- Sort custom posts by date and then by taxonomy
- 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 related CPT with custom taxonomy
- Display post count for a specific month
- display post count in archive page that have relation with another taxonomy term
- build child and anchestor three from post parent
- meta query condition don’t work
- Custom query result empty on page 2
- Use WP_query to match post types based on custom field values
- WP_Query to display number of custom post type filtered (order by) taxonomy
- WP_Query for custom taxonomies showing posts from non-specified terms?
- meta query multiple values for the same key
- Sort custom post archives by a meta value from a different custom post type?
- Live search by custom tag
- Custom post types – meta_query: search lesson which starts sooner
- Query a custom taxonomy in a function to create an csv file
- WP_Query based on ‘s’ and tax_queries
- Custom search for a custom post type in WordPress
- WP_query sort by taxonomy
- Custom Taxonomy – fields
- CPT Loop, include taxonomies and disclude others?
- post type => ‘any’ not applied my custom queries
- Ajax load more inside custom post type taxonomy
- How can I get the last 5 element of this tax query?
- tax_query not working?
- Getting Custom Posts with Custom Taxonomy
- How to get the posts that my following users are liked?
- Meta_Query refuses to return results
- Create a custom wp_query from a specific custom post type with specific taxonomy
- The most recent post of custom taxonomy
- Error get_posts with Custom Taxonomy and OR relation
- Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?
- Problems with the WP_Query query for a Custom post type
- How to show post which has the specific taxonomy terms?
- Displaying WordPress posts from post and custom post type in custom taxonomy
- Display all Custom taxonomy terms and their relevant custom posts
- Querying, storing, and using data from 2 separate custom post types
- Query events post type after current date and timezone
- Get posts of an specific term of a custom taxonomy
- Query pulling all taxonomies, not one I am specifying
- Query breaking with ‘posts_per_page’ => -1
- Conditional posts in WP_query for search
- Checking Taxonomy Terms for a Custom Post Type With get_the_terms Not Working
- CPT Efficient way to display posts from different categories with custom query
- Get archive of posts separated by taxonomies and subtaxonomies
- Query Pulling the same post twice
- Custom post type and custom taxonomies display
- WP_Query for CPT with filter by another WP_Query
- Get posts associated with custom taxonomy alternate way
- How to pass taxonomy terms to WP_Query along with $args?
- WordPress custom post type
- Loop with Custom Post Type and Taxonomies
- Custom Taxonomy Query by Taxonomny not working
- How to query posts by meta keys AND under specific category?
- Shortcode display CPT Query only showing 1 post?
- Post data in separate divs with incrementing class using WP_Query
- Selecting posts older than the current Unix epoch timestamp
- Values inside a custom field to determine which category posts to display
- Custom Query With Multiple Meta Key Value
- How to display elements of different post types?
- Storing/querying custom date data
- Trying to combine multiple WordPress queries
- WP Query Post Type with same Taxonomy name