Changing Category URL Slug

Home Forums Calendar Products Events Calendar PRO Changing Category URL Slug

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1301237
    Shaun
    Participant

    This is in reference to a closed forum topic (https://theeventscalendar.com/support/forums/topic/change-category-taxonomy-url/), but I happened upon the answer and thought I might as well share.

    Changing the default “category” slug is similar to renaming a view: https://theeventscalendar.com/knowledgebase/renaming-views/ The base naming structure will need to remain the same, but you can change the word ‘category’ to something else.

    To change “events/category” to “events/new-name-for-category”, the following should be placed in functions.php:

    function rename_event_tax_slug( $bases ) {
      if ( isset( $bases['tax'] ) ) $bases['tax'] = [ 'new-name-for-category', 'new-name-for-category' ];
      return $bases;
    }
    
    add_filter( 'tribe_events_rewrite_base_slug', 'rename_event_tax_slugs', 20 );

    Hope that helps?

    • This topic was modified 8 years, 10 months ago by Shaun.
    #1301990
    Andras
    Keymaster

    Hi Shaun,

    Thanks for sharing that. That is awesome!

    Note that there are 2 typos in there, for the function name and the filter name is missing an “s”, so this is how it should look:

    function rename_event_tax_slugs ( $bases ) {
    if ( isset( $bases['tax'] ) ) $bases['tax'] = [ 'new-name-for-category', 'new-name-for-category' ];
    return $bases;
    }
    add_filter( 'tribe_events_rewrite_base_slugs', 'rename_event_tax_slugs', 20 );
    

    Thanks and cheers,
    Andras

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Changing Category URL Slug’ is closed to new replies.