• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » How to Exclude Posts from a Particular Category at WordPress Home

By Abhishek Ghosh June 6, 2022 5:27 pm Updated on June 6, 2022

How to Exclude Posts from a Particular Category at WordPress Home

Advertisement

Usually, we use a semi-static webpage for WordPress home. It is a quite natural fact that we want to highlight posts from certain categories on the WordPress home page. For various reasons, we need to publish a few articles “irrelevant” to the site’s niche. For the sake of SEO, we should try to exclude such posts from our WordPress home page.

In case you want the sponsored posts not to appear on your home page for a few days, then you should create a new category to temporarily show the posts. You have to manually move to the “vanishing category” after a certain time so that the home archive does not have the articles.

 

How to Exclude Posts from a Particular Category

 

First, there is an excellent plugin named “Ultimate Category Excluder”. You can search for this plugin from your WordPress “Add New” plugin page or visit the official repository at WordPress.ORG :

Advertisement

---

Vim
1
https://wordpress.org/plugins/ultimate-category-excluder/

All you have to do is, activate the plugin and navigate to the settings page of the plugin. Usually, this is the last part of the URL:

Vim
1
2
3
/wp-admin/options-general.php?page=ultimate-category-excluder.php
## example
# https://example.com/wp-admin/options-general.php?page=ultimate-category-excluder.php

Use this page to select the categories you wish to exclude and where you would like to exclude them from such as home page, feed, all archives, search etc. Remember that this will not vanish the articles from the search engine result page. This plugin is slightly a bigger hammer for our needs.

 

Snippets to Exclude Posts from a Particular Category

 

If you add the below snippet to your theme’s functions.php file, it will vanish the articles from the category you’ll mention from WordPress homepage:

Vim
1
2
3
4
5
6
7
8
function exclude_category_home( $query ) {
if ( $query->is_home ) {
$query->set( 'cat', '-2' );
}
return $query;
}
add_filter( 'pre_get_posts', 'exclude_category_home' );

Please notice this line:

Vim
1
$query->set( 'cat', '-2' );

Here we have mentioned the category as minus 2. If you want to exclude category 15, then you should mention as minus 15 :

Vim
1
2
3
4
5
6
7
8
function exclude_category_home( $query ) {
if ( $query->is_home ) {
$query->set( 'cat', '-15' );
}
return $query;
}
add_filter( 'pre_get_posts', 'exclude_category_home' );

If you want to vanish articles from multiple categories, then you can simply add then after a comma mark:

Vim
1
2
3
4
5
6
7
8
function exclude_category_home( $query ) {
if ( $query->is_home ) {
$query->set( 'cat', '-15, -2, -10' );
}
return $query;
}
add_filter( 'pre_get_posts', 'exclude_category_home' );

Remember that the below format is incorrect :

Vim
1
'cat', '-15', '-2', '-10'

In our one old article, we mentioned about a plugin to avoid adding snippets on theme‘s functions.php file.

How to Exclude Posts from a Particular Category at WordPress Home

You can use that plugin to add the above code. Also, I have kept a ready to use plugin at GitHub repository for your testing.

This Article Has Been Shared 622 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to How to Exclude Posts from a Particular Category at WordPress Home

  • Colorful text boxes plugin to highlight text of your WordPress blog

    Special Text Boxes plugin for Wordpress helps you to highlight any text inside pre-defined boxes of different colors and icons and also you can create custom style of your own.

  • Best SEO plugin: Platinum SEO pack versus All in one SEO pack

    Both Platinum SEO pack and All in one SEO pack are good plugins. Still, it is a common question which seo pack is best for Wordpress.

  • Social sharing buttons in blogs : how many you actually need?

    Social sharing buttons in blogs has been an integral and must part especially for SEO purpose. But, how many Social sharing buttons in your blog you actually need?

  • Use WordPress SEO News Extension as Free Software

    Google News Extension comes with Free Software License. You Can Use WordPress SEO News Extension For Free By Ex-DMOZ Editor Joost de Valk.

  • IP Geo Block : Best WordPress Brute Force Plugin

    IP Geo Block is Definitely the Best WordPress Brute Force Plugin in 2016 Being Capable to Throw Custom HTTP Error Based on Country, Analyze the Attempts and Being Lighter.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Online Dating: How to Find Your Match March 20, 2023
  • Web Design Cookbook: Logo March 19, 2023
  • How Starlink Internet Works March 17, 2023
  • The Importance of a Camera Tracking System in Virtual Production March 15, 2023
  • Understanding the Key Differences between Docker and OpenVZ March 14, 2023

About This Article

Cite this article as: Abhishek Ghosh, "How to Exclude Posts from a Particular Category at WordPress Home," in The Customize Windows, June 6, 2022, March 20, 2023, https://thecustomizewindows.com/2022/06/how-to-exclude-posts-from-a-particular-category-at-wordpress-home/.

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT