{"id":1399857,"date":"2017-12-06T14:43:24","date_gmt":"2017-12-06T22:43:24","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/exclude-category-from-main-calendar-include-category-in-calendar-see-admin\/"},"modified":"2017-12-06T14:43:24","modified_gmt":"2017-12-06T22:43:24","slug":"exclude-category-from-main-calendar-include-category-in-calendar-see-admin","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/exclude-category-from-main-calendar-include-category-in-calendar-see-admin\/","title":{"rendered":"Exclude Category from Main Calendar, include category in Calendar, See Admin"},"content":{"rendered":"<p>I need to do several things all relating to one event category, &#8220;yoga.&#8221;<\/p>\n<p>1. exclude &#8220;yoga&#8221; category from the main calendar<br \/>\n2. include a category specific calendar with &#8220;yoga&#8221; only<br \/>\n3. View all events in the admin back end<\/p>\n<p>I am using a WordPress plugin that gives you the ability to easily and safely add your custom functions (PHP code) called <a href=\"https:\/\/wordpress.org\/plugins\/my-custom-functions\/\">My Custom Functions<\/a>.<\/p>\n<p>The first code I used accomplished #1 and #2, BUT Not #3.  All of the events in the &#8220;yoga&#8221; category were not accessible in the admin back end at all. They were not visible.<\/p>\n<p><strong>The code below is my second attempt.  <\/strong><br \/>\nWith this code, #1 is accomplished Main Calendar exclude yoga and #3 is accomplished &#8211; all events are in the admin area. BUT NOT #2 &#8211; the Yoga Only calendar shows no events.<\/p>\n<pre><code>&lt;?php\n\/*\n * Removes categories &quot;yoga&quot; from list and month views\n *\/\nfunction tribe_exclude_events_category( $wp_query ) {\n\n\t\/\/ Slugs for the categories you wish to hide\n\t$exclude_cats = array(&#039;yoga&#039;);\n\n\t\/\/ Include all posts on admin views\n\tif ( is_admin() ) return $wp_query;\n\n\t\/\/ Uncomment to allow admins to view all events\n\/\/\tif ( current_user_can(&#039;administrator&#039;) ) return $wp_query;\n\n\t\/\/ Join with current tax query if set\n\tif (is_array($wp_query-&gt;tax_query))\n\t\t$tax_query = $wp_query-&gt;tax_query;\n\telse\n\t\t$tax_query = array();\n\n\t\/\/ Setup an exclude from the tribe_events_cat taxonomy\n\t$tax_query[] = array(\n\t\t&#039;taxonomy&#039;  =&gt; &#039;tribe_events_cat&#039;,\n\t\t&#039;field&#039;     =&gt; &#039;slug&#039;,\n\t\t&#039;terms&#039;     =&gt; $exclude_cats,\n\t\t&#039;operator&#039;  =&gt; &#039;NOT IN&#039;\n\t);\n\n\tif (\n\t\ttribe_is_event_query()\n\/\/\t\t&amp;&amp; !is_single() \/\/ Uncomment to allow directly viewing an individual event page\n\/\/\t\t&amp;&amp; !is_tax() \/\/ Uncomment to allow directly viewing the category page\n\t) {\n\t\t$wp_query-&gt;set(&#039;tax_query&#039;, $tax_query);\n\t}\n\n\treturn $wp_query;\n\n}\n\nadd_action( &#039;pre_get_posts&#039;, &#039;tribe_exclude_events_category&#039;, 100, 1 );\n\n\/**\n * Limit events by category in Month, Photo, Week and list view\n * unless we are in a category view\n *\/\nfunction limit_events_by_category( $query ) {\n\n\tif ( ( tribe_is_month() || tribe_is_photo() || tribe_is_week() || tribe_is_list_view() ) &amp;&amp; !is_tax() ) {\n\n\t\t$query-&gt;set( &#039;tax_query&#039;, array(\n\t\t\tarray(\n\t\t\t&#039;taxonomy&#039; =&gt; TribeEvents::TAXONOMY,\n\t\t\t&#039;field&#039; =&gt; &#039;slug&#039;,\n\t\t\t&#039;terms&#039; =&gt; array(&#039;yoga&#039;)\n\t\t\t))\n\t\t);\n\n\t}\n\n\treturn $query;\n}\n\nadd_action( &#039;pre_get_posts&#039;, &#039;limit_events_by_category&#039; );\n<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-1399857","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Exclude Category from Main Calendar, include category in Calendar, See Admin -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/exclude-category-from-main-calendar-include-category-in-calendar-see-admin\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Exclude Category from Main Calendar, include category in Calendar, See Admin -\" \/>\n<meta property=\"og:description\" content=\"I need to do several things all relating to one event category, &#8220;yoga.&#8221; 1. exclude &#8220;yoga&#8221; category from the main calendar 2. include a category specific calendar with &#8220;yoga&#8221; only 3. View all events in the admin back end I am using a WordPress plugin that gives you the ability to easily and safely add [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/exclude-category-from-main-calendar-include-category-in-calendar-see-admin\/\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/exclude-category-from-main-calendar-include-category-in-calendar-see-admin\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/exclude-category-from-main-calendar-include-category-in-calendar-see-admin\/\",\"name\":\"Exclude Category from Main Calendar, include category in Calendar, See Admin -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2017-12-06T22:43:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/exclude-category-from-main-calendar-include-category-in-calendar-see-admin\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/exclude-category-from-main-calendar-include-category-in-calendar-see-admin\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/exclude-category-from-main-calendar-include-category-in-calendar-see-admin\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Calendar Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Events Calendar PRO\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Exclude Category from Main Calendar, include category in Calendar, See Admin\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Exclude Category from Main Calendar, include category in Calendar, See Admin -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/exclude-category-from-main-calendar-include-category-in-calendar-see-admin\/","og_locale":"en_US","og_type":"article","og_title":"Exclude Category from Main Calendar, include category in Calendar, See Admin -","og_description":"I need to do several things all relating to one event category, &#8220;yoga.&#8221; 1. exclude &#8220;yoga&#8221; category from the main calendar 2. include a category specific calendar with &#8220;yoga&#8221; only 3. View all events in the admin back end I am using a WordPress plugin that gives you the ability to easily and safely add [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/exclude-category-from-main-calendar-include-category-in-calendar-see-admin\/","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/exclude-category-from-main-calendar-include-category-in-calendar-see-admin\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/exclude-category-from-main-calendar-include-category-in-calendar-see-admin\/","name":"Exclude Category from Main Calendar, include category in Calendar, See Admin -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2017-12-06T22:43:24+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/exclude-category-from-main-calendar-include-category-in-calendar-see-admin\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/exclude-category-from-main-calendar-include-category-in-calendar-see-admin\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/exclude-category-from-main-calendar-include-category-in-calendar-see-admin\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Calendar Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/"},{"@type":"ListItem","position":4,"name":"Events Calendar PRO","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/"},{"@type":"ListItem","position":5,"name":"Exclude Category from Main Calendar, include category in Calendar, See Admin"}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1399857","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1399857\/revisions"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1399857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}