To exclude a category from the home page, use the pre_get_posts
action:
function exclude_category( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'cat', '-1,-1347' );
}
}
add_action( 'pre_get_posts', 'exclude_category' );
In this example, 1
and 1347
are the category IDs you’d like to exclude.
Also see the Conditional Tags page for a list of all the is_
conditionals you can use to target this function to different types of pages.
Related Posts:
- Plugin for changing a post’s category based on it’s post date?
- plugin for wp_list_categories with posts
- How can i list random post from multiple category?
- Solutions to repost categories into multisite blogs?
- Calendar Solution: Handling upcoming Dates with Posts?
- Any built-in function to associate a post to category through a plugin?
- Display by Category in Admin
- Redirect to another page using contact form 7? [closed]
- Recent posts per category loop?
- check uncategorized category by default
- WooCommerce Hiding A Certain Category From Being Displayed On Single Product
- How to get Recent Post From Each Category with Thumbnail?
- Adding custom post category to categories widget
- automatically set random featured image by category in wordpress on post
- Find And Add Category to Posts
- Retrieve post thumbnails
- How to add character to content of post?
- single.php fires more than once after clicking on any post to view with different post id each time
- Twitter List Tweets and Delicious Links as Posts
- Automatically set posts to NoIndex depending on category?
- Can i have limit posts on a specific category and automatically remove older ones?
- How to add portfolio category post count in main navigation menu?
- Manually set global $post vars with an ID, in order to use template tags
- Show a different number of posts per page depending on context (e.g., homepage, search, archive)
- Limit access to posts/pages by user roles
- How To Ignore a Filter On Applying Filter the Content In a Function
- Restrict access and display for categories
- How to get posts by content?
- WP get_permalink Return Wrong URL
- How to use get_categories() with Event Organiser plugin
- post expire after x days
- Set attached to state
- Use plugin or custom post type for game score functionality
- Tag link suggestion plugin
- Collaborative post submission [closed]
- How to set post expiration date and time and move the page to archive after expiration [closed]
- Bulk Image Uploader to create new post from each image [closed]
- Display comments of users on single page
- Post query – show posts from specified day and month and whole years
- Support for simultaneous editing
- Getting a List of Categories for Use in a Plugin?
- Accessing post’s meta data based on user’s click of a post
- View Private Published Page with URL Code (no login required)
- The problem with WordPress Importer
- Assign post format to categories
- Using WP Category Lists Plugin to Dynamically Display Category (PHP)
- Display post lists in 2nd paragraph
- Matching Chapters to a Custom posts [closed]
- Preg Match All doesn’t Allow echo first character for WordPress Taxonomy Tags
- External RSS feed to WordPress Portfolio
- how to add text to posts from tags
- WordPress “Categories to tags converter” not working. Pointing to import.php instead
- Would Gutenberg be considered a PlugIn?
- How to get the first post and second post in a wordpress blog?
- How do I publish portfolio items with a future date?
- How do I rename a category in the menu bar only?
- Ambrosite Next/Previous Post Link Plus or WP next_post_link to cycle through top level category
- WordPress plugin Post Creation [closed]
- Is changing post from category in a large blog a good practice?
- Where Should i write the code for wordpress ajax voting?
- how to execute some code after a post is published in WordPress [duplicate]
- trigger email when post is published by someone a user follows
- WP::is_main_query() Not Working
- Exclude post category in a blog page
- Embed PDF into wordpress
- Hook Scripts and Styles in WordPress
- WordPress plugin: Getting posts where checkbox selected
- How to auto strip hyperlinks & images in wordpress post
- how can authors to define custom pages?
- WP Editor, save content and category on frontend
- Plugin for TinyMCE to create reference to other posts
- Category “same post” retreive and display
- help intercepting save_post through plugin
- Update existing post dates to random dates and time
- Add a new category for posts
- .com creates automated link in post
- Is it possible to customize a wordpress post from outside dashboard(Something like site.com/post-type/post/?e=post_id)?
- How to echo a PHP Code After the Content
- WordPress Product Detail and catalog
- Category as Subdomain for One WP Install
- How to Save settings of custom tab product page in admin side in a database?
- Better code/text editing for posts and pages?
- Style WordPress Custom Post Type Single Page
- SWF in wordpress post
- Is it possible to setup Category wise Subsciption?
- Posts are deleted everyday at night
- Editing “Kahi’s Highlight Used Categories” plugin code – highlighting parent and child category in post page
- Using Postmash plugin in WordPress 3.3.1
- wp_insert_post_data filter to set category
- What is the correct method for updating post content from a plugin?
- Get post id in Post Page within Wp-admin
- PHP $_session is not work in wordpress
- Next and Previous Pagination button not displaying in WordPress
- Make a Custom template for a specific category in wordpress
- Notifications on WordPress Website [closed]
- query_vars in plugin when using custom permalinks
- Sell “create a post”, paid account for post creation
- Looking for membership style plugin with edit option [closed]
- How to pre-set WordPress settings for specific posts?
- Getting 400 Error in wordpress website