{"id":2069,"date":"2016-07-19T12:00:32","date_gmt":"2016-07-19T18:00:32","guid":{"rendered":"https:\/\/islascruz.org\/blog\/?p=2069"},"modified":"2016-07-20T15:17:45","modified_gmt":"2016-07-20T21:17:45","slug":"show-category-blog-homepage","status":"publish","type":"post","link":"https:\/\/islascruz.org\/blog\/2016\/07\/19\/show-category-blog-homepage\/","title":{"rendered":"Don&#8217;t show a particular category on blog homepage"},"content":{"rendered":"<p>For a long time I have this feeling that providing content to social networks is similar to give them money. I usually don&#8217;t get a thing when posting\u00a0or sharing content there, at least not something different than my friends\/followers noticing that.<\/p>\n<p>So, I&#8217;d like to use my blog for the sharing stuff, but sometimes that thing that I&#8217;m sharing is just too dump to be in the homepage. I didn&#8217;t knew how to hide posts from the homepage in a quick way. There is a plugin that let you set where the post could be seen (like in archives, search and stuff like that), but is not what I&#8217;m looking for, I want something simple.<\/p>\n<p>So, there is another way to do that, categories are for that, a way to group posts. Why not exclude a category from the blog home page?. With that visitors\u00a0can see the posts, the bots will be able to index them, the will be listed in searches or category listing, but still be hidden from the homepage.<\/p>\n<p>Turns out there is a pretty simple way to do that. it&#8217;s just adding a function to your theme &#8220;functions.php&#8221; to exclude that particular category.<\/p>\n<p>(?? = category id number)<\/p>\n<p>[code language=&#8221;php&#8221;]<br \/>\nfunction exclude_category($query) {<br \/>\n  if ( $query-&gt;is_home )<br \/>\n    $query-&gt;set(&#8216;cat&#8217;, &#8216;-??&#8217;);<br \/>\n  return $query;<br \/>\n}<br \/>\nadd_filter(&#8216;pre_get_posts&#8217;, &#8216;exclude_category&#8217;);<br \/>\n[\/code]<\/p>\n<p>The minus sign in front of the category id means don\u2019t include.<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_2069\" class=\"pvc_stats all  \" data-element-id=\"2069\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/islascruz.org\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>For a long time I have this feeling that providing content to social networks is similar to give them money. I usually don&#8217;t get a thing when posting\u00a0or sharing content there, at least not something different than my friends\/followers noticing that. So, I&#8217;d like to use my blog for the sharing stuff, but sometimes that [&hellip;]<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_2069\" class=\"pvc_stats all  \" data-element-id=\"2069\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/islascruz.org\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":6346,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48],"tags":[],"class_list":["post-2069","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-meta"],"brizy_media":[],"_links":{"self":[{"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/posts\/2069","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/comments?post=2069"}],"version-history":[{"count":6,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/posts\/2069\/revisions"}],"predecessor-version":[{"id":2134,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/posts\/2069\/revisions\/2134"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/media\/6346"}],"wp:attachment":[{"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/media?parent=2069"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/categories?post=2069"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/islascruz.org\/blog\/wp-json\/wp\/v2\/tags?post=2069"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}