Support

Home Forums Event Espresso Premium How to change event category slug while also removing the first path in the URL

How to change event category slug while also removing the first path in the URL

Posted: January 11, 2019 at 9:30 am


mireaux2019

January 11, 2019 at 9:30 am

Our site permalink is set to website.com/blog/ I was able to remove /blog/ from our events by adding a function with this in it, the with_front removed /blog/:

$custom_slug = array( 'slug' => 'myeventslug', 'with_front' => false );

I found this code for changing category slug, but it won’t remove the /blog/ and I don’t know how to modify it to include the with_front line


add_filter( 'FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', 'my_custom_event_category_slug');
function my_custom_event_category_slug( $thearray ) {
if ( !empty($thearray['espresso_event_categories']) ) {
$thearray['espresso_event_categories']['args']['rewrite']['slug'] = 'mycategoryslug';
return $thear
}
return $thearray;
}

Doing that code just turns the category links to website.com/blog/mycategoryslug/categoryname


Josh

  • Support Staff

January 11, 2019 at 10:20 am

This is documented in the codex:
https://codex.wordpress.org/Function_Reference/register_post_type#rewrite

so one way to do this is add another array item e.g.
$thearray['espresso_event_categories']['args']['rewrite']['with_front'] = false;

One other thing to note is
FHEE__EE_Register_CPTs__get_taxonomies__taxonomies
is deprecated. You can use
FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies
instead.


mireaux2019

January 11, 2019 at 1:58 pm

That worked, thank you!


mireaux2019

January 11, 2019 at 1:58 pm

That worked, thank you!

The support post ‘How to change event category slug while also removing the first path in the URL’ 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.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  mireaux2019 2 months, 1 week ago ago

Topic Tags

Notifications

This topic is: resolved
Do NOT follow this link or you will be banned from the site!