I want to remove all hyphens/dashes from the Custom Post Type permalink in Wordpress.

For example:




Any advice on how to do this with any functions.

  • Hi, welcome to WPSE. IMHO that is not a good idea, it will not have a good effect on your SEO, and will possibly cause confusions.
    – Jack Johansson
    Apr 18 '17 at 9:34

You need to use to hook into WordPress's sanitize title hook.

function no_dashes($title) {
    return str_replace('-', '', $title);
add_filter('sanitize_title', 'no_dashes' , 9999);

for particular post type you can use these hook

function no_dashes( $slug, $post_ID, $post_status, $post_type ) {

    if( $post_type == "page" ) {
        $slug = str_replace( '-', '', $slug);
    return $slug;
add_filter( "wp_unique_post_slug", "no_dashes", 10, 4 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.