You need to register separate routes for each scenario you want to cover (ie, cat & tag, just cat, or just tag), all done in the single add_action call. The regex you have will support the comma separated tags.
The next thing to do is change how you set the 'term'
parameter as part of the 'tax_query'
array parameter. It’s expecting an array of strings, currently you are passing a single string of comma separated values (ie, 'tag1,tag2'
). You can pass the result of using explode()
to convert the string to an array.
You will also need to implement some conditional logic around setting the 'tax_query'
array parameter based on what route is used.
Related Posts:
- Use Gravity Forms and a Shopping Cart for output to Freshbooks for an Estimate [closed]
- display posts, pages and custom post types from another wordpress site
- A question on creating filters for custom posts using taxonomy
- Conditional Query of Custom Post Type and custom taxonomy
- will post_id ever change? Can I safely use post_id for custom queries?
- List custom taxonomy specific to one custom post type
- Define new user capability for custom post types?
- How to allow visitors to enter custom post type?
- Is it possible to create relational metabox values in a custom post?
- Custom Post Type Query for Sidebar Doesn’t Work on Front Page
- Meta query for custom post type ignored in main query
- Make parts of your wordpress website completely built with data from external APIs?
- 2 Templates 1 custom post type according url
- How do I move/order posts with a tag to the end?
- changing meta value and meta key of price field
- WordPress sort search results by custom order
- Use same slug base for Custom Post Type posts, and multiple taxonomy terms
- Database to page routing API?
- Hide parent categories when clicked, and show it’s childs
- Custom Path/Folder behind a custom post type
- Time based access control of custom post types – what is good approach?
- Show titles, date of all posts on single category page
- delete_published_posts does not work
- How to start a new post with custom Taxonomies already set?
- WooCommerce sort products by the actual product width(not the shipping width)
- Create a custom php page and load it at a specific slug
- Structure of data : CPT + terms
- Exclude objects from WordPress API based from ACF field using rest_prepare_{$post_type}
- How to handle paged param in post and custom-post-type?
- Default text in a specific post type, but not visible?
- Update postmeta Parent when post_status child change
- WP_Query custom post type query not showing the exact post type
- Shortcode to display Staff post type based on Location post type and Specialty post type
- How to remove post listing page for a custom post type
- How to include term custom meta into the custom taxonomy term permalink structure
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- A form that can save/edit after first input
- Adding the_content() in custom template email
- Cannot save CPT meta box
- non-hierarchical post type with hierarchical url structure
- Send notification to the admin when new custom post is submitted
- How do i search authors from search form using author’s name
- Allow users to create posts without logging in?
- How to add attributes to taxonomies that may be different from post to post?
- Pages are not saving due to custom post type
- Migrating a taxonomy’s tags to the native category
- How to produce a sub-page-system in WordPress
- Best structure / rewrite rules to achieve the following url
- don’t publish custom post type post if a meta data field isn’t valid
- How does order=asc effect a wp_query (its acting pretty weird in a loop)
- How to sort posts in a custom post type by title in ascending order by default?
- Categorise Custom Post Types
- Detect inside a custom query the kind of post type to assign custom classes
- Pros and cons of a custom page vs custom post type template file
- custom post type vs. conditionally displaying meta boxes for specific terms?
- Edit the_content() function so to add a div wrapper
- How do you make a custom post type items automatically delete items 3 months after publication?
- Custom Post Type & Custom Menu Walker to append custom class for active post types
- Number of posts in the archive
- custom post data – how to
- Ordering Submenu Pages in WP 3.1
- 404 Error on form submission within custom post type
- Creating tags via API
- Custom URL redirect in WP
- Remove Quick edit for custom post type?
- CRUD operations in wordpress
- Replace dynamically content in a custom database table when a custom post is created
- How to customize work area / admin area in a custom post type without plugins?
- How can I have different content for different countries?
- Change “empty trash” button text?
- How to display custom field value on page?
- Move Genesis Single Page/Single Post Title
- Add an Outside Wrapper to my Header and Make it Full Width
- List Categories (wp_terms) and count posts
- attach CPT data to a taxonomy
- Displaying multiple post types on home page
- Get_the_terms restrict output
- Conflict between wp_list_pages and get_posts – list pages not displaying
- Custom post type menu
- Api rest_route 404 while building filter for custom posts (filtered by multiple meta keys / custom fields)
- How to insert data into meta box from another plugin?
- why post_class() function apply css classes to all other files?
- Custom REST endpoint not working to retrieve single posts (“rest_no_route”)
- Custom post type’s posts are not showing anywere but in xml sitemap
- YOAST SEO won’t work on custom post type archive [closed]
- Creating a non-hierarchical Taxonomy that behaves like categories
- List All Custom Post Types Posts in Nav Menu Dynamically
- Only show columns in custom post type?
- How to Create a Separate Page for Blog Posts in WordPress
- Display custom post type for specific user
- WordPress as a backend for external service? [closed]
- Separate Content from gallery (custom post type)
- How to get the current category with custom posts
- Display Custom Post Types Glossary
- Custom Post type content within a slider
- post_content is stripping HTML when adding a new post? [closed]
- How to export custom post type with ACF to individual file with automation?
- WordPress Count posts within a custom post type
- Add custom columns in custom post type browse page
- Displaying a custom post type using get_template_part into a specific layout