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
- Write WP Query that selects posts that are part of the same two categories
- wp_query on page template not working (Genesis framework)
- Pagination for custom loop on custom page template is not displaying anything
- WP_User_Query orderby meta_val_num
- WP_Query custom order and pagination
- how to load posts to a custom post template after using template_redirect or template_include
- How to create Page templates for showing Blog posts in different layouts?
- How to SQL query posts IDs by categories AND authors?
- Unable to paginate a custom page query
- Include one page/post into query which is already returning posts
- I am officially missing something about transient posts
- Insert images into wordpress post with a query
- Why doesn’t my WP Meta Query return any results?
- WP_Query meta compare must include ALL array values
- Start Query from 2nd Post without offset
- Disable (or limit) queries when certain content (or data) is not needed (or showed)
- Display upcoming events in the next 30 days by querying posts with timestamp in custom meta
- Page template doesn’t display simple HTML if inserted into other page?
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- meta_query where the meta value is not the post title
- Post incorrectly excluded when using “category__in”?
- Query multiple post types, but different order for each
- Multi-layered WP_Query
- `offset` WP_Query argument dont work via `pre_get_posts`
- Filter products on category AND tag
- Display posts ONLY from the current logged in user and current week/year/month Elementor posts
- How to separate two columns from one content on a page template?
- What’s the best way to make a blog page on WordPress?
- Pagination of custom page with custom fields query
- Query pages created by deleted users
- 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
- Form checkbox value going to dynamic URL
- setting offset to category number in archive page
- Woocommerce Get Orders By Meta Value
- Any way to use FETCH_KEY_PAIR with $wpdb?
- pre_user_query vs pre_get_posts
- Exclude post from wp_query based on custom field boolean
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- Get posts that match defined arrays of tags
- Doing $wpdb->get_results returns NULL, doing the same query in my DB returns correct value
- Move some posts to end of sort order, even if there is a sort in the wp_Query already
- Adding nofollow to all the post links in get_posts with pre_get_posts or WP_Query
- INNER JOIN custom tables – SQL Query
- Meta query orderby meta_value_num sorting by role first
- How to get meta key list efficiently?
- Order posts by tags count?
- Query against multiple locations within single custom post type post
- Why pagination is not working with tax_query param?
- Pagination Shows Up But Won’t Work on Custom Gallery Page
- Query Posts | Combining multiple form inputs into query arguments to generate one filter result
- Strange results from WP_Query
- Is there a way to control both Order By and Order query parameters from one input field
- How to get_comments() ordered by date and parent?
- I need query_posts() to order results first by a meta value and then by post ID
- WP_Query & Duplicate entries
- How to query 5 users in random who have published more than 10 posts
- How to query users by post count no less than 10
- WP Query. Ordering posts by another post types meta
- Add to search posts query array with post IDS which will appear first
- return child post if available otherwise parent post
- Search has query that will return no results
- Is my code correct?
- How to make a search query if not found in post table then search in postmeta table?
- Slow wp_posts and wp_postmeta query using Advance Custom Fields
- WP Query – Search in title or author_name
- Query by meta value (add a dropdown of all values)
- Meta query doesn’t remove placeholder escape before query
- WP_Query about meta_key and its array value
- Create global array to compare inside a query
- How to show post title in content editor in backend?
- How to exclude posts by ID within a category/archive loop
- How to show terms from another taxonomy
- Adding Category in WP_Query Not Working
- My entry results are not consistently alphabetized
- Merge two queries and remove duplicate
- What is the best way to reset a search on a meta_key / meta_value?
- Ignoring ‘a’ when sorting posts
- how to show more than 1 post into three columns query
- How can I modify standard search query to include also ACF custom fields values?
- 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?
- Fetch only categorized posts
- Bring a post to the top of the query if it’s in a certain category?
- orderby in WP_QUERY – Use the order from the Dashboard
- Fetching $_POST from Page Template into functions.php
- Random posts in WP_Query when searching by tag
- WP_Query with child element
- Custom query for tag and custom tag from 2 post type
- wpdb get_results() returns only 2 rows
- Custom pagination (Title, date and teaser)
- Ordering Posts by parent category, name ascending
- Query posts in current category but not attachment format
- Filter posts/pages by user_role array
- WP_Query always returning the last custom post
- WP_Query secondary query failing
- How to get query results for the next page