{"id":6352,"date":"2016-02-29T12:50:45","date_gmt":"2016-02-29T17:50:45","guid":{"rendered":"https:\/\/themespress.ca\/?p=6352"},"modified":"2022-09-10T18:21:55","modified_gmt":"2022-09-10T22:21:55","slug":"exclude-category-from-archives","status":"publish","type":"post","link":"https:\/\/themespress.ca\/en\/exclude-category-from-archives\/","title":{"rendered":"Excluding a Category from Archives"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><div class=\"vc_row wpb_row vc_row-fluid\"><div class=\"wpb_column vc_column_container vc_col-sm-12\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\">\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>What&#8217;s my category&#8217;s ID?<\/p>\n<p>In order to get your category&#8217;s ID, simply go in the Category section. Click on the Category in question and the ID will be displayed in the URL as such: <\/p>\n<p><a href=\"https:\/\/themespress.ca\/wp-content\/uploads\/2016\/02\/Exclure-une-categorie-des-archives-Front-Page-WordPress.png\" rel=\"attachment wp-att-530\"><img decoding=\"async\" class=\"alignnone size-full wp-image-530\" src=\"https:\/\/themespress.ca\/wp-content\/uploads\/2016\/02\/Exclure-une-categorie-des-archives-Front-Page-WordPress.png\" alt=\"Exclure une cat\u00e9gorie des archives \/ Front Page WordPress\" width=\"658\" height=\"38\" \/><\/a><\/p>\n<p>Here&#8217;s the function we&#8217;ve used with the pre_get_posts filter.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-7387393\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-7387393\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"php\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">add_action(&#039;pre_get_posts&#039;, &#039;remove_themespress_post_categories&#039; );\nfunction remove_themespress_post_categories( $wp_query ) {\n  \/\/ 31 = ID de ma cat&eacute;gorie\n  $remove_cat = &#039;-31&#039;;\n  \/\/ supprimer des archives feeds, search, and home page, mais pas admin ou category\n  if( (is_home() || ( is_archive() &amp;&amp; !is_category() &amp;&amp; !is_tag() )) &amp;&amp; !is_admin()) {\n    set_query_var(&#039;cat&#039;, $remove_cat);\n  }\n}<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>We could also used this option via a Query Post. Here are a few examples of\u00a0<a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/query_posts\" target=\"_blank\" rel=\"noopener\">Query Posts<\/a>.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<\/div><\/div><\/div><\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"What's my category's ID? In order to get your category's ID, simply go in the Category section. Click on the Category in question and the ID will be displayed in<div class=\"read-more\"><a class=\"btn button-secondary\" href=\"https:\/\/themespress.ca\/en\/exclude-category-from-archives\/\">Read More<\/a><\/div>","protected":false},"author":81,"featured_media":4512,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[283],"tags":[318],"class_list":["post-6352","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-functions"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/6352","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/users\/81"}],"replies":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/comments?post=6352"}],"version-history":[{"count":0,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/6352\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media\/4512"}],"wp:attachment":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media?parent=6352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/categories?post=6352"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/tags?post=6352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}