How do i change the search permanent links

This snippet should solve your problem. Just put it into your functions.php file.

function my_insert_rewrite_rules( $rules ) {
    $newrules = array();
    $newrules['search/([^/]+)/post_type/([^/]+)/?$'] = 'index.php?s=$matches[1]&post_type=$matches[2]';
    return $newrules + $rules;
}
add_filter( 'rewrite_rules_array','my_insert_rewrite_rules' );


function my_flush_rewrite_rules() {
    flush_rewrite_rules();
}
add_action( 'after_switch_theme', 'my_flush_rewrite_rules' );

You will have to flush rewrite rules after adding this code, before it will start to work. Just switch theme to another and back or go to Settings->Permalink Settings and push “Save” button.

Leave a Comment