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?
- Create terms when registering taxonomy?
- How do I edit pre_get_post for the category the user is currently in?
- Display only one result from “get_the_category_list”
- Assign an icon to a category post
- Custom Category/Subcategory structure
- Category archive page – loop through posts of certain tag (with pagination) – pre_get_posts
- Remove ‘rel’ attributes from the_category() output
- Default category link for a custom category is a broken link
- 3 Columns, 3 Categories, One Archive, and Pagination
- Send to different single pages by category when multiple categories exist
- How can you change the permalink for pages?
- woocommerce related products by specific categories [closed]
- Adding a block with query in homepage
- multiple values in an array for category__and does not work with WP_Query
- Add properties to term object
- Display all Categories
- How to target all woocommerce categories that don’t have any subcategories in them?
- create post with main category and other categories from admin panel
- get_posts – require all categories
- How do you add Author and date Published on Category Pages?
- Twenty Eleven Theme [duplicate]
- display certain category on custom template page
- Get post by Category in custom template
- comments_number fails to print
- How to show child category name & post from it’s parent [closed]