Support

Home Forums Event Espresso Premium How do I change the slug for events?

How do I change the slug for events?

Posted: June 16, 2014 at 5:41 pm


Trish Harris

June 16, 2014 at 5:41 pm

Hey there,

I would like to change http://sharpmachine.dev/events/music-theory-intensive/ to http://sharpmachine.dev/classes/music-theory-intensive/

How do I do so?


Josh

  • Support Staff

June 16, 2014 at 7:09 pm

Hi Trish,

Event Espresso 4 has a filter that lets you change the slug for events. There is some documentation on how to use the filter here:

https://eventespresso.com/wiki/change-events-cpt-slug/

The code you can use for classes is:

add_filter( 'FHEE__EE_Register_CPTs__register_CPT__rewrite', 'my_custom_event_slug', 10, 2 );
    function my_custom_event_slug( $slug, $post_type ) {
    	if ( $post_type == 'espresso_events' ) {
    		$custom_slug = array( 'slug' => 'classes' );
    		return $custom_slug;
    	}
    	return $slug;
    }


Trish Harris

June 16, 2014 at 8:03 pm

Hey Josh,

This isn’t working. I made sure to update the permalinks, etc, and it’s not changing.


Josh

  • Support Staff

June 16, 2014 at 8:11 pm

Hi Trish,

May I ask where you added the code snippet? If it was a new plugin (which we recommend) did the plugin get activated?


Trish Harris

June 16, 2014 at 8:23 pm

Hey Josh,

I put it in my themes function.php file. The article you referenced above does state “You can change this by adding a code snippet to your theme’s functions.php file”

Also, I’m using EE3, not EE4.


Josh

  • Support Staff

June 16, 2014 at 8:56 pm

Since you’re using ee3, that’s going to involve a different section of code. If you open up /event-espresso/includes/admin-files/custom_post_type.php and look at line 34 you’ll find:

'rewrite' => array("slug" => "events"),

You can change the slug there.


Trish Harris

June 16, 2014 at 9:51 pm

I’d rather not touch the plugin files because I’ll have to change that line every time the plugin is updated. No way to do it from my functions.php?


Josh

  • Support Staff

June 16, 2014 at 10:26 pm

Not currently, but we could add a filter in there for a future version of Event Espresso 3.

The support post ‘How do I change the slug for events?’ 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.

Event Espresso