Lush

How to Change the URL of a Post Type

All post types have a default slug name. If we want to replace "domainName.com/event/fun-night" by "domainName.com/tour/fun-night" we have to:

-Activate the child theme.

-Add this code at the end of the lush-child/functions.php file

function update_post_slug( $args, $post_type ) {
    if ( 'event' === $post_type ) {
        $my_args = array(
            'rewrite' => array( 'slug' => 'tour', 'with_front' => false )
        );
        return array_merge( $args, $my_args );
    }
    return $args;
}
add_filter( 'register_post_type_args', 'update_post_slug', 10, 2 );

*We have to replace "event" in the script by the slug we want to customize, and "tour" by its new slug name.

-Finally we have to go to wp-admin>settings>permalinks to re-generate permalinks.