WordPress doesn’t handle this logic qutomatically so you will have do do it manually.
What you need to do is:
-
Read the url parameter with get_query_var( ‘category_name’ );
-
injects it in your custom WP_Query:
$custom_query_args = array( 'post_type' => 'post', 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array( 'post-format-audio' ), ), array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => get_query_var( 'category_name' ), ) ) );
Note that if you decide to pass an arbitrary variable instead of category_name, you will need to declare it before using it.
See https://developer.wordpress.org/reference/functions/get_query_var/
Related Posts:
- URL to Post Archive of Custom Query
- Pagination is not working on custom query inside a custom home page template
- When should you use WP_Query vs query_posts() vs get_posts()?
- order by numeric value for meta value
- How to query for most viewed posts and show top 5
- WP_Comment_Query pagination, delving into the unknown
- Sort posts by category name and title
- Custom WP_Query order by post_meta and (author) user_meta
- WP_Query for WooCommerce Products
- Perform query with meta_value date
- Highlighting Sub topic in a post?
- how to retrieve specific product attribute value in an sql query?
- WordPress custom archive page
- WP_query category__in not working, only pulls from first category
- What are the differences between “Latest Posts” and “Static Page”?
- Splitting the main query in multiple loops with query_posts and/or pre_get_posts?
- Retrieve or Query Pages by ID
- How to capture a variable query string, then append it to all URLs in a WordPress site
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- How to do a query on custom taxonomies that is uncategorised?
- Empty tax_query array returns an empty array
- WP_Query doesn’t get sticky post at the top, when used in a page template
- Meta Query for specific months
- How do I search inside specific taxonomies in WordPress
- Different string for specifed post type on posts listing at homepage
- if/else on custom query gives 200 OK when condition not met?
- How to correctly pass values to wpdb->prepare()?
- Setting get_queried_object
- Pagination of a WP_Query Loop in a child-page page template
- remove query arg from url after set query
- difference between like ‘%%%var%%’ and ‘%var%’
- list pages using page.php and NOT page-{slug}.php
- Changing WP_Query params with url Query Var
- only delete post within query / for each statement (front end)
- How to detect if query is runned from widget?
- Sort query by author: 1 author, then others
- Overwrite YoastSEO meta-tags with another page’s [closed]
- WordPress Pagination changes my template
- How to orderby multiple meta fields if some fields are empty
- How to duplicate 5 posts out of WP_Query results?
- WP_query sorting can’t sort danish letters (æ, ø, å)
- Slow queries on a huge database
- Multisite pagination issue by multi query archive 404
- Query with relation and one without relation using multiple taxonomies?
- How to get list of posts from permalinks?
- Is there a reason why Pages are not publicly_queryable?
- Check return value of get_posts
- Exclude some authors from query
- Transient api Caches confused
- How can I override one post and make it display content for another post?
- Get multiple users with meta value in one query and populate WP_User class
- Get a list of posts by specific category
- WordPress Query String: get_posts(‘cat=5’) vs WP_Query( ‘cat=5’) vs URL: /site/?cat=5
- How to check the array values, what WP_Query has brought to me?
- How to add custom meta to ‘pre_get_terms’?
- Shortcode for custom query not returning results when attributes are added
- Should I reset $wp_query?
- inserting content of 1 Post to in another with a template hierarchy
- Get specific ACF key and value from all posts – no access to DB
- WP_Query with multiple orderby NOT working with ASC and DESC, what’s wrong?
- wp_query on page template not working (Genesis framework)
- Pagination for custom loop on custom page template is not displaying anything
- I am officially missing something about transient posts
- Start Query from 2nd Post without offset
- Display upcoming events in the next 30 days by querying posts with timestamp in custom meta
- Post incorrectly excluded when using “category__in”?
- Display posts ONLY from the current logged in user and current week/year/month Elementor posts
- How to use custom page for all posts with custom url, call another directory?
- Custom Taxonomy Archive Page to display either ALL listings or only from URL
- Any way to use FETCH_KEY_PAIR with $wpdb?
- INNER JOIN custom tables – SQL Query
- Query against multiple locations within single custom post type post
- How to query users by post count no less than 10
- WP Query. Ordering posts by another post types meta
- How to make a search query if not found in post table then search in postmeta table?
- WP_Query about meta_key and its array value
- Create global array to compare inside a query
- how to show more than 1 post into three columns query
- How can I use a specific wordpress page template if certain words are used in page title [closed]
- Using the same WP_Query for shop and widgets in WooCommerce shop
- How can I get all the posts that are related with a specific taxonomy term?
- Filter posts/pages by user_role array
- WP_Query secondary query failing
- Search Functionality broken by the wp 4.2 update
- Issue attempting a wp_query_posts with tags
- Passing query variables to a custom page template
- add_query_vars does not work
- Retrieve posts in custom post type and specific taxonomies
- Custom post types loop on a page template
- Get the number of rows from $wpdb->get_results not working
- Parsing External Table Arguments
- Get Child Custom Post Content on Single.php?
- difference between methods of query
- Query posts by meta value and sort by another meta key
- How much does $wpdb->prepare(), then $wpdb->query() VS straight $wpdb->query(), can slow down the load time of whole page
- how to use transient method?
- Pre_get_post on CPT archive page
- Get posts that were most recently tagged
- wp_query order by rand is repeating posts
- Advanced Search – Is this possible?