Default Category for Community Events

Home Forums Calendar Products Community Events Default Category for Community Events

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1359238
    Bradley Pirman
    Participant

    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!

    #1360272
    Jennifer
    Keymaster

    Hi 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

    #1360335
    Bradley Pirman
    Participant

    This 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 )

    #1360696
    Jennifer
    Keymaster

    No 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

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Default Category for Community Events’ is closed to new replies.