There is no simple way to do this via WP_Query()
. Depending how many categories you have, the following may not be a good idea. If you have ~20 you may be ok. So, instead of saying “all posts excluding ones in 37”, you would do “get me everything in all terms (not specifying term_id 37”).
To do this you need to use a category__in
for all your other categories:
// Get all the category IDs (except 37)
$categories = get_terms( 'category', array( 'exclude' => array( 37 ), 'fields' => 'ids' ) );
query_posts( array( 'category__in' => $categories ) );
This will get you all posts that are in a category other than/aswel as 37. However, doing this on a large amount of categories will start to slow the query down (I am thinking +40,000 posts for example).
Related Posts:
- Get posts from sites in Multisite?
- How To Modify The Loop in archives.php To Have 11 Posts Per Page and CSS Styling
- Using categories & “stickyness” together
- Does the ‘cat’ argument in query_posts fetch posts from subcategories as well as the given ID?
- List posts by category exclude current post
- Display only the latest post from multiple categories
- Select category in custom query
- Display one latest post from multiple categories
- Return category slug / title from category ID
- Exclude category from loop not working
- Best way to programmatically link to multiple categories (union/intersection) [closed]
- Post count for category and tag
- Checking for two categories in query_posts
- How to query post like normal search would do. within search.php page
- Query Posts Exclude Entire Category
- how to query posts and auto assign category if post title has keyword
- How do I call posts with a certain tag?
- Modify WordPress SQL Query to pull from within a category
- query order by category
- Get link which associated with a specific category and tag
- Order by category titles
- Have parent category contain only one post?
- List posts in alphabetical order
- Randomly load categories with latest post
- Set colors depending on category
- How do I query_posts in cat=1 AND not in cat=2
- List all posts in a category with query_post() function
- query_post order desc
- Exclude a category from a query that includes its parent category
- Show the latest post from child category?
- Finding the category id’s on category intersection pages
- Pagination on category.php and tag.php not working
- Problem with different query loops (and “main loop”) on category template page!
- query_posts not reading correct categories
- Pagination for query_posts();
- Posts from a category on homepage with category archieves page default css
- function query_posts disabling current_page_menu class
- query_posts by category_name and custom taxonomy
- wordpress taxonomy query posts
- PHP dynamical conditional post display
- Posts of specific category on page and excluded from index.htm
- new WP_Query issues
- how can i hide category?
- Displaying links to all posts of the same category on the post page
- Post not found when filtered by category ID
- Exclude categories from postquery
- Sort posts alphabetically by category/custom taxonomy, insert divider between different types
- Show posts from category specified using a custom field
- query_post problem
- Add class to current post in query_post
- Different post slug based on archive
- Pagination does not work with query_posts()
- Assign a class to first element in category in loop
- How to display products with multiple conditions, product_id and category_id
- Query post only from categories that have subcategories
- Displaying posts by year
- Paginate WordPress Category Pages
- How to have a category not show up in query post with page panigation?
- Query pages by category
- Showing one post from each category, paged?
- How To Find Out WordPress Category Table in MYSQL?
- Add custom field to Category
- Get Default Post Category From Settings
- Are Categories, Tags and Custom Taxonomies any different in regards to SEO?
- Display list of Sub-Categories and the posts they contain, within one main Category
- Create subdomains for tags and categories
- Categories – create a new separate set right after the default?
- How to get this only in small letters (lowercase)? [closed]
- Is there a function to cause empty categories not to show in menus?
- How do I count how many top level categories there are?
- display most popular tags of category?
- How to add custom script to the particular Product Category page
- get_cat_ID() not wokring
- Get all sub-categories of a parent category
- How to get category name from URL and pass to a template
- Display Categories, Sub-categories, and Sub-sub-categories on separate pages
- WooCommerce IF statements not working
- Hide woocommerce category name from specific pages
- How to display categories which contains particular tag?
- category permalinks
- Displaying Child Categories in carousel
- Is there an easy way to get a list of Category IDs?
- How to customize my category pages
- Not showing list if there aren’t any categories to display
- How to display a value inside a post with a specified category from a category custom field? [closed]
- How to let the user create a selection of categories via the backend
- Media (images, videos, etc.) not showing on Category page
- Problem with Custom Post Type Categories
- Display post thumbnail for specific category outside the loop
- Displaying categories in different template problem
- Get_term_meta() does not work with pre_get_posts()
- how to display categories for a specific post?
- show posts found in multiple categories via category_name query string?
- Display last postings of 5 categories on homepage
- Category that can hold only specific number of post
- How to add the sidebar in all category page
- Use same wordpress category base and tags as the prefix as the post permalink
- Adding category to existing post (uploaded file)
- how to create a page that shows all of multiple category posts on a single page
- Quick Edit on taxonomy names results in error