Hi @webburada ,
As per the wordpress default behavior, we can not change it from our plugin side, but you can achieve this functionality by changing the wordpress default behavior using the below code.
You need to add below filter in functions.php to remove the slug from the permalink:
function wpem_remove_slug_event_listing_slug( $post_link, $post, $leavename ) {
if ( 'event_listing' != $post->post_type || 'publish' != $post->post_status ) {
return $post_link;
}
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
return $post_link;
}
add_filter( 'post_type_link', 'wpem_remove_slug_event_listing_slug', 10, 3 );
After adding this, you’ll get a 404 page because WordPress only expects posts and pages to behave this way. So, you’ll also need to add below action in our functions.php file :
function wpem_parse_request( $query ) {
if ( ! $query->is_main_query() || 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) {
return;
}
if ( ! empty( $query->query['name'] ) ) {
$query->set( 'post_type', array( 'post', 'event_listing', 'page' ) );
}
}
add_action( 'pre_get_posts', 'wpem_parse_request' );
Now, you have to refresh your permalinks from our wordpress backend Settings tab, then you can verify in your single event page by removing “event” from url, page will work fine.
Thank you.