Posted: February 9, 2019 at 10:40 am
|
I didn’t see an option for a feature request anywhere, so I’m just posting this on the forum. I too really need the ability to hide certain event categories from a calendar (as per described here: https://eventespresso.com/topic/does-events-shortcode-allow-hiding-a-category/). Unfortunately, I don’t think the custom PHP script offered won’t work as is, because for my use I need to have a “second” special use calendar on my website that displays events for just one category (which is enabled by the event_category_id= shortcode), however, I also need to EXCLUDE this category from my primary calendar. The interim solution is to use the “show” shortcode for all my categories except the one I don’t want on my primary calendar, but this is cumbersome and not an ideal long-term solution. I hope this is a capability EE can consider for a future release. |
|
Figured I’d share that interim solution I decided to pursue was to establish a “default” category that all my normal events are included in, and use that category id with the event_category_id= parameter in the primary calendar. The trick is I just have to remember to check that category box for every new event. |
Hi, This code snippet should work for your use case because it’s intended to hide a category conditionally, depending on the current page. In other words, you can remove a specific category for your primary calendar page. |
|
|
Hi Josh, I have a couple of question about that snippet, specifically about line 12 and line 20. My perception is line 20 is where I put the category ID I want excluded from my primary training calendar (or multiple ids, separated by commas, it appears). But regarding line 12; I don’t recognize under the function of the term_relationships or term_taxonomy_id elements. Also, it’s unclear to me how this code distinguishes which calendar I want it to apply towards? |
Hi, You don’t actually change line 20. Line 12 is where you put the category ID. The example code on line 12 is removing event category ID 12. The other code you change is on line 19, where the example has: |
|
|
Below is the code I tried based on your guidance, but the events I want to exclude (event_category_id=67) from the calendar are still appearing. I tried changing “term_taxonomy_id” to “event_category_id” – no effect. I tried changing “is_page” to is_post” – and that threw an error. I don’t know what else to try next? Just to clarify, is this code actually intended to work with the calendar and not specifically the events table?
|
You don’t change that part, because event_category_id isn’t a valid parameter. How about we try a different approach? You can use this custom snippet instead: https://gist.github.com/joshfeck/cb2c0c00e15dbbd3489e35187722a402 |
|
|
Tried it and received a “nonce_failure” error upon Update File on the Edit Themes page (via WP Menu -> Appearance -> Editor -> functions.php [child] |
You can avoid the nonce_failure, and avoid bringing down your entire site if you make a mistake, by using a code editor & FTP to edit code. Generally speaking, the code editor that’s built in to WordPress should never be used for editing PHP code. |
|
|
I wasn’t aware of that – good to know. In the meantime, I got it work – thank you! |
The support post ‘Hide a Category Shortcode Needed’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.