Rather than performing a separate query, to exclude a category (or any other taxonomy) term, you can hook into pre_get_posts
:
add_action('pre_get_posts', 'wpse41820_exclude_cat_from_front_page');
function wpse41820_exclude_cat_from_front_page( $query ){
if( $query->is_main_query() && is_front_page() ){
$tax_query = array(array(
'taxonomy' => 'category',
'field' => 'id',
'terms' => array( 57 ),
'operator' => 'NOT IN'
));
$query->set('tax_query',$tax_query);
}
return $query;
}
To exclude a slug, alter the $tax_query
accordingly:
$tax_query = array(array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => array( 'term-slug' ),
'operator' => 'NOT IN'
));
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
- Exclude a category and post_type from wp_query
- 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]
- 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?
- Get all categories and posts in those categories
- How to display non-hierarchical taxonomy as terms with checkboxes?
- Combine two taxonomies in a hierarchical tree
- Get the number of posts in a named category, outside the loop
- Test if post has a category
- I want to order categories based upon the latest post time
- Highlight current category in wp_list_categories
- How to find all posts without category and assign the “Uncategorized”?
- How to Override default update_count_callback for category
- WordPress previous_post_link exclude posts with multiple categories
- Is it possible to put tags and category information in the post as text?
- Let visitors post comments on category page
- Is it possible to post with Word 2007 via XML-RPC and limit categories by user?
- how to get the categories for a single post in a hierarchical way
- Getting categories id for all products in cart
- How to Filter categories in the permalink structure
- Is there a cleaner way to get post count for a category in category.php?
- Show archives by year from just one category
- Post count for category and tag
- Is having thousands of unique categories a concern?
- How to make the link to the category for a post go to corresponding page number in archive?
- How to build a simple nav system of custom post type categories and its posts?
- How to insert category list into post creation page, and retrieve chosen categories?
- Shortcode interpreted as text
- scaleability of tags
- Grouping post-types in loop
- Having problems with paging
- So my theme doesn’t have a category.php file
- Template hierarchy: how to let category.php conditionally-load archive.php?
- Getting Category Children
- Child Category Conditional Question
- Break down output of wp_list_categories
- Get the ID of the current post’s child category
- get category name in admin screen
- Include specific category in URL automatically
- WordPress Category Page Layout
- get_the_category – display only a single category for a post (not all categories)
- It is possible to display related posts from same category as the current post?
- Remove WP Core canonical for category pagination
- Create categories manually in database
- Hide specific category link from showing
- How can I add HTML classes for current taxonomy/term hierarchy into my pages to simplify styles?
- Display List of Categories Within a Custom Taxonomy
- add custom option to get_categories dropdown
- Category as subdomain
- get_category_parents displays an empty category
- Why is my post categories not displaying?
- Unassign uncategorized from post with 2 or more categories
- WordPress category gives 404 after moving to a different domain
- How to load/include category templates based on conditionals?
- Why does WordPress append a bullet to my category tag?
- how to implement next/prev within category archive?