Support

Home Forums Event Espresso Premium How can i change default event url with EE4 version

How can i change default event url with EE4 version

Posted: September 2, 2014 at 12:19 am

Viewing 4 reply threads


Jay Sangal

September 2, 2014 at 12:19 am

Hiii,
i want to use event espresso plugin for organizing Training and courses, so that i have to change default events slug of the event listing page and single event url followed by events/… slug

here is my link http://newforce.prevwproject.com/newforce/events/ here i want to change events slug to http://newforce.prevwproject.com/newforce/trainig/

i am using this code to my theme functions.php to override events slug, but it doesn’t works.

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 == ‘training’ ) {
$custom_slug = array( ‘slug’ => ‘training’ );
return $custom_slug;
}
return $slug;
}

Could you please help out to resolve this.


Tony

  • Support Staff

September 2, 2014 at 12:52 am

Hi Jay,

Its not working because of this line:

if ( $post_type == ‘training’ ) {

That’s basically saying if the post type is training set the slug to training. But there is no ‘training’ post type, you want to target the espresso_events post type.

So you need something like this

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' => 'training' );
    		return $custom_slug;
    	}
    	return $slug;
    }

Which says if the post type is espresso_events, use the ‘training’ slug.

Don’t forget to flush permalinks once you’ve corrected that code. (Go to Settings -> Permalinks, make no changes and just hit save)

Does that help?


Jay Sangal

September 6, 2014 at 5:19 am

Hi Tony,
sorry for late answer, i tried with your corrected code but i didn’t found any changes or effect, using the code in themes fuctions.php file
my event slug is not changed, i am unable access event page to edit permalink of event.


Lorenzo Orlando Caum

  • Support Staff

September 6, 2014 at 11:01 am

Hello,

Try removing any existing filters for the slug. Then save pretty permalinks through Settings –> Permalinks.

Then add the code that Tony shared to your theme’s functions.php file (be sure its the correct site) using an SFTP or FTP client.

Then return to your WordPress dashboard and browse to the permalinks page.


Lorenzo


Jay Sangal

September 11, 2014 at 6:32 am

Hey guys,
Its Working Correctly thanks for all your support…

thanks

Viewing 4 reply threads

The support post ‘How can i change default event url with EE4 version’ 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