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
- 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]
- 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 Find Out WordPress Category Table in MYSQL?
- Add custom field to Category
- Does the ‘cat’ argument in query_posts fetch posts from subcategories as well as the given ID?
- Are Categories, Tags and Custom Taxonomies any different in regards to SEO?
- How to get this only in small letters (lowercase)? [closed]
- Redirecting category link to first child post
- has_category() for parent category
- Getting the sub category
- When to use ‘get_category_by_path’ vs. ‘get_term_by’ to get category object from `get_query_var( ‘category_name’ )`?
- One WP install, I need to map a custom domain name to each category
- Show thumbnail for category?
- get_the_category_list() does not give me all my categories
- How to disable category without deleting?
- How to get category name from URL and pass to a template
- Displaying multiple loops based off of category
- Display Categories, Sub-categories, and Sub-sub-categories on separate pages
- WooCommerce IF statements not working
- Category pie diagram meta box in post editing page
- There any way to get de percentage of number of post by user and category?
- How to display categories which contains particular tag?
- Exclude Category filter from Portfolio section
- Exclude current post from loop
- Removing Uncategorized on post save if other category present?
- WordPress Categories in data-groups
- Not showing list if there aren’t any categories to display
- How to list all categories and their IDs using SQL query?
- How to order get_categories() in the same order as the menu?
- Show different menu on each woocommerce category page
- How to let the user create a selection of categories via the backend
- Display subcategories selectbox on each category page
- Get posts in a subcategory of a chosen parent
- How can I only display links from a child category
- Problem with Custom Post Type Categories
- Category Template – Show Last Entry as Featured
- can I ‘combine’ categories as a menu item?
- List taxonomy terms assigned to a post in hierarchical view
- Count how many posts have a specified tag AND category
- Show the parent taxonomy by creating shortcode in woocommerce?
- Post List by category and under custom taxonomy
- Balance Tags to the_content Words Length
- How to create template for children category?
- Categories and Tags Conflict after Woocommerce Installation
- how to display categories for a specific post?
- the_content() not showing full posts in category template
- Show parent category if there is no subcategory
- Add category links?
- Removing categories, Comments etc from posts?
- Add html word before category
- Problem importing categories and sub-categories
- how to ask if in two categorys inside if
- How to list out post category name and description in page
- Print child category slug nicename