Looking at the codebase, the only difference appears to be that category__not_in
excludes child terms from selection, whereas cat
does not.
Should category__not_in
be used with caution, similar to posts__not_in
? Absolutely, but for different reasons. The main issue with excluding posts is that it causes problems for caching – every query with a different excluded post ID requires a separate cache entry, significantly negating the advantage of caching. Excluding terms, meanwhile, requires more JOINs in the query, and is therefore detrimental to performance.
Related Posts:
- Meta_query compare operator explanation
- Exclude post ID from wp_query
- paginate_links() adds empty href to first page and previous link
- Get array of posts from the current archive page loop
- Custom query incorrectly returning everything [closed]
- Last post ordered by publish date using WP_Query on front page
- Query certain amount of posts from multiple dates
- Meta Query with date and time on the same Day before given time
- In loop: posts have thumbnail AND other variables
- Orderby = none not working [duplicate]
- Add inline HTML to posts published within last 24hrs
- Add and in the header while looping over custom query in page template
- Single page theme
- Pagination not working on static page
- WordPress pagination link always leads to home page
- Query posts with more than 20 comments
- Can certain (site-crashing) limitations on WP_Query in shortcode be overcome?
- Get array of current post term ID’s
- Including only current user’s posts in search
- Implementing an OR statement to wordpress wp_query
- How can i simulate “taxonomy__in” in query?
- Refine search results using WP_Query
- query_posts: how to show all ‘meta_value’ containing a specific word?
- How to show subcategories using loop?
- Minimize database queries to user tables?
- add_filter() depending on search term
- Get all products which have both product category
- How to make Meta Query case sensitive?
- Populate tax_query terms parameter with post term
- Orderby the sum of several numeric custom meta fields
- Fastest way of counting posts of a custom post type in a specific taxonomy term?
- wp_query ‘s’, search filter with pagination is not working
- Why is wp_query causing an uncaught error to is_user_logged_in() not defined?
- Modify wp-query and sort by post meta key
- Check if loop has any categories?
- WordPress query with items from more than one selfdefined taxonomy as `term` argument
- How to display an other custom post type in a different custom post type’s archive?
- Replacing raw database query to WP_Query
- get_post_meta in WP_Query
- How to alter local query, not main query [duplicate]
- WP CLI can’t delete plugin related table
- Inserting HTML to close and open divs in WP_Query loops
- Change query from cat id to slug or name?
- Query only the posts with a post format of “audio”
- Display Current Post’s Position in Custom Taxonomy
- Using Wp_Query without the loop?
- infinite loop in wp_query using simple query
- Custom WP_Query id
- wp query for popular post with simple field
- Parent and child categories
- Set post number to single posts
- Orderby custom meta returns random order
- get_post() is not returning correct value
- How does WP generate the default $query in WP_Query based on the URL?
- Intiger meta value with ‘>=’ returns posts with lower value
- Update query for wp_posts and wp_postmeta
- How to print term name inside wp post loop
- Grabbing taxonomy terms and inserting them into an array
- custom page with post content using read more
- WP_Query with page_ids in arguments without a result
- how to put thumbnail below category’s title?
- Woocommerce Shortcode which displays a table with product data
- JOIN filter doesn’t work in WP_Query in wp-ajax calls
- Why is my pagination /page/2 taking me to index.php?
- Creating a query that get all posts but places meta items first
- get_posts query is taking about 40 seconds to execute
- Customize the Sorting Dropdown in WooCommerce use another list or more page
- How to wp_query every Sunday between a startdate and enddate?
- Why last row deleted when refresh page
- WP_Query by MAX post_id?
- Adding nofollow to all the post links in get_posts with pre_get_posts or WP_Query
- Meta query orderby meta_value_num sorting by role first
- Query post by Category and custom file (ACF)
- Add to search posts query array with post IDS which will appear first
- Can’t reset the secondary query by wp_reset_postdata()
- Filtering ‘Featured’ posts from a batch of category IDs
- Wp_query ordering problem
- Meta Query if Values Don’t Exist
- Letting wordpress decide what template and page to use based on condition
- Why does the theme insert the comments section if I don’t reset my custom WP_Query?
- Get post Number with local loop and template
- WP_Query tax_query only returning posts that match first term
- Get post related to current post
- How to show all the associated posts with specific date of data metabox?
- Problems with WP_Query, Loop, a condition and Posts per Page
- Issue attempting a wp_query_posts with tags
- Custom Search Query – include only custom fields and title
- Passing query variables to a custom page template
- Multiple homepage layouts as selected by user from theme options
- Get Child Custom Post Content on Single.php?
- Exclude categories and subcategories in QueryLoop
- meta_query in wp_query not working as expected
- How much does $wpdb->prepare(), then $wpdb->query() VS straight $wpdb->query(), can slow down the load time of whole page
- No exposure on search engines
- WP query based on two meta queries
- WordPress website links redirect to homepage
- How to display posts from a specific term first then another posts from another terms using tax_query
- How to include custom fields in wordpress search
- Extend search query to search meta keys values based on search string
- AJAX multiple search boxes not merging with array merge