How to remove slug from CPT correctly?
This is a two-step process. First, you need to remove the slug from the default URL. (use a unique slug while registering the CPT). function wpse413969_remove_cpt_slug( $post_link, $post ) { if ( $post->post_type == ‘YOUR_CPT’ && $post->post_status == ‘publish’) { $post_link = str_replace( “https://wordpress.stackexchange.com/” . $post->post_type . “https://wordpress.stackexchange.com/”, “https://wordpress.stackexchange.com/”, $post_link ); } return $post_link; } … Read more