• 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 258 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 (22.1K 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

  • Ways To Make Sure Your Online Course Outshine Others July 3, 2022
  • Will Smart Factories Become the New Assembly Line? July 2, 2022
  • The Cost of Doing Business as a Handyman July 1, 2022
  • Samsung Galaxy S22 Ultra: Long Term Review June 30, 2022
  • How to Make the Most of Your S Pen (S22 Ultra) June 29, 2022

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, July 5, 2022, https://thecustomizewindows.com/2022/06/how-to-exclude-posts-from-a-particular-category-at-wordpress-home/.

Source:The Customize Windows, JiMA.in

This website uses cookies. If you do not want to allow us to use cookies and/or non-personalized Ads, kindly clear browser cookies after closing this webpage.

Read Privacy Policy.

PC users can consult Corrine Chorney for Security.

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

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

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