{"id":130,"date":"2019-02-08T03:50:16","date_gmt":"2019-02-08T03:50:16","guid":{"rendered":"https:\/\/mumbaiwebhosting.co.in\/portal\/?p=130"},"modified":"2019-03-08T03:12:12","modified_gmt":"2019-03-08T03:12:12","slug":"exclude-a-category-from-wordpress-homepage","status":"publish","type":"post","link":"https:\/\/mumbaiwebhosting.co.in\/portal\/exclude-a-category-from-wordpress-homepage\/","title":{"rendered":"Exclude a category from WordPress homepage"},"content":{"rendered":"\r\n<p>By default, WordPress displays posts from all categories on out homepage. In some cases, we may not want that. In this article, we will show you how to easily exclude a category from WordPress homepage.<\/p>\r\n\r\n\r\n\r\n<p>WordPress allows you to sort content into categories and tags. Now sometimes we may want to use a category for posts that are not part of your normal blog entries.<\/p>\r\n\r\n\r\n\r\n<p>By default, WordPress does not allow us to hide posts in specific categories from homepage or archives. This leaves us with unwanted posts appearing on your homepage.<\/p>\r\n\r\n\r\n\r\n<p>let\u2019s see the methods to exclude\u00a0a category from WordPress homepage<\/p>\r\n\r\n\r\n\r\n<h3>Method 1: Exclude a Category from WordPress Using Plugin<\/h3>\r\n\r\n\r\n\r\n<p>First thing you need to do is to install and activate the\u00a0Ultimate Category Excluder\u00a0plugin. For more details, you should follow our guide on\u00a0how to install a WordPress plugin.<\/p>\r\n\r\n\r\n\r\n<p>Upon activation, you\u2019ll need to go to\u00a0Settings \u00bb Category Excluder\u00a0page. It will display all the categories that are available on your WordPress blog.<\/p>\r\n\r\n\r\n\r\n<p>From here, you can simply check one or multiple categories under the \u2018Exclude from front page\u2019 column. If you want, then you can also exclude the category from\u00a0RSS feeds, archives, or even from\u00a0WordPress search.<\/p>\r\n\r\n\r\n\r\n<p>click on the\u00a0Update\u00a0button to store these settings.<\/p>\r\n\r\n\r\n\r\n<h3>Method 2: Exclude a Category from WordPress Homepage Using Code<\/h3>\r\n\r\n\r\n\r\n<p>This method requires you to add code to your WordPress files.\u00a0You will need to add following code to your theme\u2019s\u00a0functions.php\u00a0file or a\u00a0site-specific plugin.<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-preformatted\">function exclude_category_home( $query ) {\r\nif ( $query-&gt;is_home ) {\r\n$query-&gt;set( 'cat', '-6,-10,-11' );\r\n}\r\nreturn $query;\r\n}\r\n \r\nadd_filter( 'pre_get_posts', 'exclude_category_home' );<\/pre>\r\n\r\n\r\n\r\n<p>Simply replace the IDs (-6, -10, -11) with your category IDs to exclude them from your WordPress homepage.<\/p>\r\n\r\n\r\n\r\n<p>Hope this article helped you learn how to exclude a category from your WordPress homepage. visit our blog regularly to get new updates.<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>By default, WordPress displays posts from all categories on out homepage. In some cases, we may not want that. In this article, we will show you how to easily exclude&#8230; <a class=\"read-more-link\" href=\"https:\/\/mumbaiwebhosting.co.in\/portal\/exclude-a-category-from-wordpress-homepage\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/mumbaiwebhosting.co.in\/portal\/wp-json\/wp\/v2\/posts\/130"}],"collection":[{"href":"https:\/\/mumbaiwebhosting.co.in\/portal\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mumbaiwebhosting.co.in\/portal\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mumbaiwebhosting.co.in\/portal\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mumbaiwebhosting.co.in\/portal\/wp-json\/wp\/v2\/comments?post=130"}],"version-history":[{"count":2,"href":"https:\/\/mumbaiwebhosting.co.in\/portal\/wp-json\/wp\/v2\/posts\/130\/revisions"}],"predecessor-version":[{"id":155,"href":"https:\/\/mumbaiwebhosting.co.in\/portal\/wp-json\/wp\/v2\/posts\/130\/revisions\/155"}],"wp:attachment":[{"href":"https:\/\/mumbaiwebhosting.co.in\/portal\/wp-json\/wp\/v2\/media?parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mumbaiwebhosting.co.in\/portal\/wp-json\/wp\/v2\/categories?post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mumbaiwebhosting.co.in\/portal\/wp-json\/wp\/v2\/tags?post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}