Support

Home Forums Event Espresso Premium How do we change the custom post type slug for ee4

How do we change the custom post type slug for ee4

Posted: February 21, 2014 at 11:19 am


Shaun Conway

February 21, 2014 at 11:19 am

Hey,

We already have a main part of site using slug /events can we change the custom post type of ee4 to say.. /tickets?


Lorenzo Orlando Caum

  • Support Staff

February 21, 2014 at 11:30 am

Hi Shaun,

You can make this change in EE4. Here is an example:

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

It should be added to your theme’s functions.php file.

Cheers


Lorenzo


Shaun Conway

February 21, 2014 at 11:34 am

Awesome and thanks for quick response. One follow up. Is /tickets a good idea or does EE use that slug for any of the ticketing add ons? Might as well get it right from the start.


Lorenzo Orlando Caum

  • Support Staff

February 21, 2014 at 12:17 pm

Hi Shaun,

You can use any slug that you would like that is not already in use by WordPress. I provided an example for tickets since you mentioned that in your original post. This won’t affect how the Ticketing add-on works.

Let us know if there is anything else we can help with. Just open a new support topic through the Event Espresso Support Forums. Have an awesome Friday!


Lorenzo


Shaun Conway

February 25, 2014 at 7:26 pm

Hey hope this still gets through or I can open a new topic.

So we used the code above to change the ee4 slug to /tickets. We created the page /tickets and added the [ESPRESSO_EVENTS] shortcode. The page will not load. When we add the shortcode to the /events page the listing page loaded.

When we try to load a single event, which still has the /tickets/event name, the page will not load. I noticed on the general settings page, it still has the event listing URL as /events

I noticed the newest release solved a similar issue for event listing and detail page. I am wondering if that means we need to add some more changes to our code to change the slug. Please let me know if we are missing anything


Lorenzo Orlando Caum

  • Support Staff

February 25, 2014 at 7:56 pm

Could you relocate the filter towards the middle of your theme’s functions.php file?

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

Then please go to WP-admin –> Settings –> Permalinks and resave the existing settings to flush the existing permalinks.

Let me know if this helps.


Lorenzo


Josh

  • Support Staff

February 26, 2014 at 6:21 am

Hi Shaun,

It happens to turn out that the CPT slug and a page are two different things. When Event Espresso registers the custom post type there cannot be a page with the same slug. You will need to trash the tickets page if you want to use tickets as the CPT slug.

A page that has [ESPRESSO_EVENTS] on it will display a list of events that you can filter with parameters. It does not replace the custom post type archive.


Shaun Conway

February 26, 2014 at 2:36 pm

Hey,
Lorenzo we attempted to move the code to a different spot on the file and it did not make a difference.

Josh we tried it without the slug and it was not loading, so we tried adding the slug and the short code with as maybe a possibility. We just removed the slug, refreshed perms links and we are having the same no load issue. I went through all items to make sure the slug did not exist.

I am looking to have this work in conjunction with the event platform I already have on the site. I might be missing this somewhere, but is there a location for all ee4 shortcodes? Maybe that will be enough to get this thing rolling. Going through shortcode documentation I feel as if I end up in some ee3 info by mistake. Knowing exactly what shortcodes I currently have available for ee4 would be awesome….like I said this might be me just missing it somewhere.

Thanks.


Josh

  • Support Staff

February 26, 2014 at 4:50 pm

The location of the shortcode info is inside the Event Espresso 4 Help and Support tab in the WP admin.

You might have better success with the custom post type slug function if you place it into a snippet plugin. Your theme’s functions.php file may be loading the function too late.


Lorenzo Orlando Caum

  • Support Staff

September 12, 2015 at 4:30 pm

Hey there Shaun,

I wanted to let you know that there is an enhancement for this that is now available in the current version of Event Espresso 4.

You no longer need to use the filter that is mentioned here to change the events custom post type slug:

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

Instead, you can remove that filter if it is currently in place. Then login to your WordPress dashboard and go to Event Espresso –> Events –> Templates. Then scroll to the Event Listing area and you’ll see an option to specify your slug for the espresso_events custom post type. Here is an example of what it looks like:

http://cl.ly/image/0W3V2L1p1d1q

Note that the option above is available in the current version of Event Espresso 4. If you are running an older version of Event Espresso 4, then please see the steps below for how to upgrade to the current version.

Steps for upgrading Event Espresso 4

First, please backup your WordPress site. Then upgrade to the latest version of Event Espresso 4.

You can see the changelog for Event Espresso 4 here:

https://eventespresso.com/wiki/ee4-changelog/


Lorenzo

The support post ‘How do we change the custom post type slug for ee4’ 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