Home › Forums › Calendar Products › Community Events › Default Category for Community Events
- This topic has 4 replies, 3 voices, and was last updated 6 years, 6 months ago by Bradley Pirman.
-
AuthorPosts
-
October 4, 2017 at 2:48 pm #1359238Bradley PirmanParticipant
Hi there,
Is there a way to assign a default event category to all community events submitted?
We don’t want users to be able to select categories so we’ve hidden the taxonomy pickers via CSS. Now we just want to assign all events as “Community Events” in our event categories.
Thanks!
October 6, 2017 at 7:10 am #1360272JenniferKeymasterHi Bradley,
Thanks for reaching out!
There isn’t an out of the box way to do this, but you can do it with a small customization. First, you can copy the template for that page into your child theme by following these instructions. The template can be found at wp-content/plugins/the-events-calendar-community-events/src/views/community/modules/taxonomy.php. You can then add the following code to the template in your child theme, just above the foreach block on line 42:
// set default category
if ( 'tribe_events_cat' === $taxonomy && 0 === get_the_ID() && empty( $value ) ) {
$value = array(16); // Default category term ID
}You’ll need to replace the ’16’ with the ID for the category you want to set as the default. You can find the category ID by going to Events > Event Categories and clicking on the category – it will appear in the URL (see screenshot).
Let me know how that works for you!
Thanks,
Jennifer
October 6, 2017 at 8:59 am #1360335Bradley PirmanParticipantThis code snippet solved the issue right away. Thanks!
I placed my custom version (with the code snippet added at line 41) in /wp-content/themes/<mytheme>/tribe-events/community/modules/taxonomy.php
Thanks for your help!
( WordPress v4.8.2, Community Events plugin v.4.5.6 )
October 7, 2017 at 12:54 am #1360696JenniferKeymasterNo problem, I’m glad that worked for you! I’ll go ahead and close out this thread, but please feel free to open a new one if you have any other questions!
Thanks,
Jennifer
-
AuthorPosts
- The topic ‘Default Category for Community Events’ is closed to new replies.