You can use simply category__not_in
parameter to exclude one or several categories from your result.
The sample is like this:
$query = new WP_Query( array( 'category__not_in' => array( 2, 6 ) ) );
To see list of available parameters and complete example, see documentation of WP_Query in developer.wordpress.org
I hope you can use it.
Related Posts:
- exclude category from get_posts?
- Exclude the category from the WordPress loop
- Exclude certain category from latest updates
- Exclude categories from Loop, queries, widgets, post navigation
- List posts by category exclude current post
- wp_list_categories exclude not working
- Excluding a category from next and previous post links
- Exclude Category From Home Page, Display Posts on It’s Own Page?
- How to exclude categories from recent posts, recent comments & category widgets?
- Exclude a category from the filed under list only on some templates
- How to exclude posts from a category when using this particular format
- Exclude category from Tag Template
- exclude post from displaying in loop if it is in a category, but not in many categories
- I need to create a search form that will display search results from specific category
- Exclude Posts From Specific Category from Next and Previous post links
- Query Posts Exclude Entire Category
- exclude categories from search results
- Exclude category from fucntion
- WordPress category widget only show categories with children
- wp_list_pages() exclude category
- Exclude category from query
- Functions.php: Exclude Category from “Blog”
- Woocommerce filter function not updating
- wp_list_categories not excluing multiple ids
- How to exclude posts from category posts count
- Exclude category from foreach loop
- Have posts that belong to multiple categories, exclude some categories from homepage
- Exclude all subcategories in the_category (post)
- I need to exclude from a query a category and a few custom taxonomies
- Exclude categories by ID
- Homepage custom recent news
- Exclude the category in WordPress
- How can I exclude a category from the main loop with the category name & not ID?
- User level categories
- Exclude category from drop down list form
- exclude certain categories form archive widget
- How to remove an item from a custom Walker_Nav_Menu
- How can I exclude a particular category from my WordPress Page 1 and Page 2?
- Exclude category from WP_Query args not working
- Displaying Category in sidebar post widget but not in the loop on home
- Category menu that filters out empty categories
- Problems with explode [closed]
- Exclude Category From Home Page, Display Posts on It’s Own Page?
- How to have a category not show up in query post with page panigation?
- Customize category query in widget
- Call function on a single page
- Excluding cateory not working on my site. how to solve this? [closed]
- How to define category ID in an array?
- How to show posts of an columnized different categories on the same line or row?
- Echo one category as title when post has multiple categories?
- I use same slug name for category and page
- Showing all the posts in one page?
- On Category page, How can I get the category ID?
- How to order categories in Woocommerce that are spread over multiple pages? [closed]
- How do I display the posts from a custom post type on a category.php page?
- Automatically add product_categories to nav_menu
- Add Product categories to WordPress menu without losing hierarchy
- How to change number of items on add new pluggins page from backend?
- How to display posts under a specific subcategory of a given category
- Ignoring a category in WP_Query still shows the links in next_post_link()?
- Implementing a tricky wordpress menu (nested categories + thumbnails)
- If posts category is “cars”, display image
- query in category.php repeats itself
- How can I add more “filters” to my products? (Categories, attributes, etc.)
- How to “group” (categorize) the Pages together?
- Is There a Difference Between Taxonomies and Categories?
- Related Tags not in category
- Hooking to walker_nav_menu_start_el to insert list of subpages
- Show the latest post from child category?
- How to show a list of only categories (exclude subcategories)
- How to list categories in reverse alphabetical order?
- How to add categories on a page [duplicate]
- How to hide some categories in dashboard
- Getting the first parent of a hierarchical term
- Include either name or slug in the include parameter using wp_list_categories?
- get cat id is not working from custom taxonomy
- Show the current post’s category, without displaying parent category
- get all categories’ latest post in one query
- change image on single product page with js
- How to get all post categories without custom post type categories?
- Get Categories of multiple posts
- How Can I Display the Category Description in a Theme with no Category.php or Archive.php?
- How do I merge WooCommerce categories with the same name?
- Custom get_the_password_form
- In ACF, how to show custom category selection tab upon selecting a main category
- WooCommerce – Get products from category right before deleting category
- omit categories from main navigation menu
- How to relocate images
- Category next page link not working
- How to display the past events in one of the category?
- Category archives
- Category For Pages In WordPress
- Inserting categories as a hierarchical terms from frontend form
- category__and works, but why?
- Page Type with Category Link
- If I change the taxonomy of a post will it get a new time stamp?
- Display post of current parent category, and in right hand side show child category post
- Category pagination not working in category.php please help me
- Print the associated categories of the current post starting with parent (with option to remove href)
- completely confused with archive.php, category.php