As @milo said in the comments, the cat
parameter (and similar parameters in other hierarchical taxonomies) will make the query look in subcategories as well. If you do not want that to happen use the category__in
parameter.
As for the general slowness, it is hard to guess, but it depends on your DB server performance (maybe it is under constant load and it is time to upgrade it) and how “deep” are those posts in the table.
Last but not least, if you do not need the information of how many matching results exist beyond your limit, you should try adding 'no_found_rows' => true
to your query. That way the DB will not try to calculate the number of total posts in the category (the SQL_CALC_FOUND_ROWS
part of the query)
Related Posts:
- Is it possible to dynamically get queried term AND taxonomy?
- How do I search inside specific taxonomies in WordPress
- Pass array of taxonomy terms to wp_query
- How to add custom meta to ‘pre_get_terms’?
- How to show terms from another taxonomy
- How can I get all the posts that are related with a specific taxonomy term?
- When should you use WP_Query vs query_posts() vs get_posts()?
- order by numeric value for meta value
- Wp get all the sub pages of the parent using wp query
- Return only Count from a wp_query request?
- How to query for most viewed posts and show top 5
- WP_Query vs get_posts
- WP_Comment_Query pagination, delving into the unknown
- Usage of the new “posts_clauses” filter in WordPress 3.1?
- WP query taxonomy input differs to output?
- Make a WP Query search match exactly the search term
- Search custom taxonomy term by name
- WP_Query: query posts by ids from array?
- Changing the meta_query of the main query based on custom query_vars and using pre_get_posts
- Sort posts by category name and title
- How to uniquely identify queries?
- What is the most efficient way of querying posts based on visits and date for current day?
- Custom WP_Query order by post_meta and (author) user_meta
- Query WooCommerce orders where meta data does not exist
- How to display post from current Taxonomy in archive page?
- WP_Query for WooCommerce Products
- pre_get_posts with get_posts
- Display posts the match taxonomy term linked from wp_list_categoies?
- author.php with ACF and CPTs
- Query Custom Meta Value with Increment
- Why is my WP_Query not working when tax_query terms are an array?
- When should you use wp_reset_postdata vs wp_reset_query?
- Get posts by meta data OR title
- Identify which loop you are hooking into; primary or secondary?
- Perform query with meta_value date
- WP_Query ordered by custom field that is a date string?
- How to make an activities stream mixing posts and comments?
- Duplicate Queries
- How to query for a week using key => value WP_Query argument notation?
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- Show only oldest post by author
- Order posts by tags count?
- SQL query equivalent to WP User Query
- Add and in the header while looping over custom query in page template
- How to get the posts published in last two days using WP_Query?
- Move posts to top of WP_Query if in certain Taxonomy?
- Highlighting Sub topic in a post?
- Which custom query am I in and how can I access its properties & methods?
- How to count post type that has a particular term?
- Querying Multiple Custom Taxonomy Terms
- Finding the next 5 posts
- how to retrieve specific product attribute value in an sql query?
- Dynamically Override Fancy Title – Part II
- Transient pagination not working properly
- Foreach-generated custom tax queries, each with an ajax “Load more” button
- Can not switch the queried post in pre_get_posts hook
- view queries made?
- Filter and list posts of a custom taxonomy
- meta_query on a date range using an array of values
- WP_Query Performance Issues with meta_query
- WP Query – Get WooCommerce Products with variation that is in stock
- WordPress custom archive page
- How to speed up wp_query, took more 5s to run against 100k posts
- WP_query category__in not working, only pulls from first category
- How to detect custom query inside `posts_where` hook?
- Pass the same object to multiple widgets in a template with one query
- Is temporarily overwriting $wp_query a bad idea?
- Get the post permalink within the loop but without additional DB query
- Query Set Order By Author
- Filter WordPress posts by between parameter
- List the 5 most recent child pages
- Splitting the main query in multiple loops with query_posts and/or pre_get_posts?
- Retrieve or Query Pages by ID
- How to Modify Taxonomy Archive Page with Search Parameter?
- How to add terms to my tax_query based off of the current post
- How do you query wordpress posts using a math formula between multiple meta field values?
- Filtering posts by custom field value not working
- Custom Post order for homepage
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- Get image of latest post from taxonomies/categories
- How to output different posts per page?
- Display link to taxonomy archive only if it has posts with certain custom field values
- How to do a query on custom taxonomies that is uncategorised?
- Page navigation doesn’t show when query category
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- Undefined WP_Query::has_posts()?
- Order taxonomy terms in alphabetical order
- WP Query for variable taxonomies
- Empty tax_query array returns an empty array
- Meta Query for specific months
- What is considered a default query for the request filter?
- Create ONE callback for all page templates, post filter queries + paginated pages, triggering pagination via AJAX
- $wpdb insert is not work
- Different string for specifed post type on posts listing at homepage
- How to orderby meta_value_num with dollar ($) sign
- if/else on custom query gives 200 OK when condition not met?
- Pull post meta with post_query?
- How to find exact match for search term in WP_Query? What is the additional string added in LIKE query in WP_Query?
- Formulate a url to show posts with both taxonomy terms
- How to correctly pass values to wpdb->prepare()?