http://codex.wordpress.org/Function_Reference/is_main_query
add_action( 'pre_get_posts', 'foo_modify_query_exclude_category' );
function foo_modify_query_exclude_category( $query ) {
if ( $query->is_main_query() && ! $query->get( 'cat' ) )
$query->set( 'cat', '-5' );
}
So it’s quite obvious to how exclude certain categories from within a
template, …
Actually it’s not. Are you talking about query_posts() !?
Related Posts:
- exclude category from get_posts?
- 404 Error On Category and Tags Pages
- 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?
- Block multiple categories from Blog
- How to exclude categories from recent posts, recent comments & category widgets?
- Exclude a category from the filed under list only on some templates
- If newest post of category is newest post in general, skip first post of category
- 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
- How to create button to direct to certain category
- 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
- WordPress Genesis not excluding category from blog
- Query Posts Exclude Entire Category
- exclude categories from search results
- Exclude category from fucntion
- WordPress category widget only show categories with children
- Putting a Category of posts under a Page
- how to “not” display new posts with a specific category on the main page?
- wp_list_pages() exclude category
- Exclude category from query
- How can I display tags as categories?
- Display content from a specific category using cat ID not working
- Woocommerce filter function not updating
- wp_list_categories not excluing multiple ids
- Display subcategories in dropdown
- Exclude post category in a blog page
- Hide a category of posts from main blog, and only show in category view
- How to exclude posts from category posts count
- Exclude category from foreach loop
- Add code to header based on category for specific posts?
- Have posts that belong to multiple categories, exclude some categories from homepage
- Exclude all subcategories in the_category (post)
- Use blog as base for tags and categories
- I need to exclude from a query a category and a few custom taxonomies
- Exclude categories by ID
- Restrict CSS on one page
- Rebuilding a Site: How to Show Several Category Posts in Woo Framework Theme?
- 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
- excude a specidic category from showing in the “relative posts”
- Category post count is not correct
- How to create category filter on a blog like on the site below?
- Blog page with posts from specific categories
- Is it possible to set up blog categories without changing permalink structure
- How to remove an item from a custom Walker_Nav_Menu
- Exclude a category and post_type from wp_query
- Redirect Category pages to blog page with query string
- 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
- Read More showing only on first post
- List post categories that link to a page showing those posts
- Category menu that filters out empty categories
- Pages, Categories, and working with someone else’s code
- Multiple Categories under one URL, where ‘Front Page’ is used already
- Problems with explode [closed]
- Exclude Category From Home Page, Display Posts on It’s Own Page?
- Restricting certain blog posts by date?
- 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?
- exclude certain categories from the list at the end of the blog post
- Exclude category when displaying all categories assigned to a post
- How to update blog post categories in WordPress?
- How to create an automatic MultiColoumn MegaMenu with Categories WordPress
- Is There a Difference Between Taxonomies and Categories?
- List all subcategories from category
- How To Find Out WordPress Category Table in MYSQL?
- Add custom field to Category
- Get Category ID inside Category template
- Only one category per post
- WordPress Multisite – global categories
- Get the children of the parent category
- Get posts from sites in Multisite?
- WP REST API: filter by category 1 AND category 2
- How To Get Parent Category Slug of Current Post
- Display All Products by Category with WooCommerce
- What is the difference between a “tag” and a “category”?
- Is there an easy way to make a meta box have the tabs like the Categories meta box has?
- How to check if I’m on the last page of posts?
- Display posts from the same category using next/previous post link
- How would I get a taxonomy/category list inside a Gutenberg block?
- Can I set a default featured image for a category?
- Check if a post is in any child category of a parent category
- How to export and import taxonomies (category, tag and/or custom taxonomy) and their terms
- Force category choice before creating new post?