Is it possible to use the plus sign instead of the dash as the word delimiter in the url? And if so, how exactly would that be done?

e.g.: www.example.com/some-title/ becomes www.example.com/some+title/

Of course, ideally it would have to work with posts, pages and custom posts.

  • 3
    Is there any particular reason you want this done? It doesn't seem like it would have many benefits and it would be a fairly complicated change to make. Apr 12, 2011 at 19:21

2 Answers 2


Mark Jaquith uses "+" as the search query string delimiter in his Nice Search Plugin. Here's what he does:

function cws_nice_search_redirect() {
    if ( is_search() && strpos( $_SERVER['REQUEST_URI'], '/wp-admin/' ) === false && strpos( $_SERVER['REQUEST_URI'], '/search/' ) === false ) {
        wp_redirect( home_url( '/search/' . str_replace( array( ' ', '%20' ),  array( '+', '+' ), get_query_var( 's' ) ) ) );

Perhaps it may be of some use for reference?

  • Yeah, but + changes to a space when it's run through urldecode(), which WP does when matching against rewrite rules. You'd need to make sure you're checking against the correct slug in WP_Query, as well as modifying the permalink output, and maybe even filtering on redirect_canonical. Apr 12, 2011 at 19:24
  • Doesn't Mark's code run after URL rewrites are applied? (mod_rewrite is all still a bit of a mystery to me) Apr 12, 2011 at 19:49
  • Yes, but spaces in searches are ok. If you have a space in the slug you look up, it won't match what's in the database. Apr 12, 2011 at 20:27
  • Sorry, to answer your question, I don't know when his code runs, but it redirects the page request to use the plus signs, so you get a fresh load starting with plus signs. Apr 12, 2011 at 20:28


Its madness, WP will generate links with - and your site will be in evergreen looping by .htaccess... Instead, you need to modify url generation code:

Insert this in functions.php:

add_action( 'wp_ajax_sample-permalink', 'MyajaxSamplePermalink',1);
function MyajaxSamplePermalink($data) {
    // check that we're dealing with a product, and editing the slug
    $post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0;
    $new_title = isset($_POST['new_title'])? $_POST['new_title'] : null;
    $post_name = isset($_POST['new_slug'])? $_POST['new_slug'] : $new_title;
    //on first fire, there is not set the "new_slug"
    $_POST['new_slug'] = ISSET($_POST['new_slug']) ? $_POST['new_slug'] : slug_modify($post_name); 
//disable slug beforehand Post Update  action (also, in navigation menus and etc...)
add_filter('name_save_pre', 'MyfilterNameSavePre');
function MyfilterNameSavePre($post_name) { 
    if (!empty($_POST['post_ID']) || !empty($_POST['post_name']) || !empty($_POST['post_title']) ){
        // check that we're dealing with a product, and editing the slug
        $post_id = !empty($_POST['post_ID']) ? intval($_POST['post_ID']) : 0;
        $new_slug = !empty($_POST['post_name']) ? $_POST['post_name'] :  $_POST['post_title'];
        //if got from new post
        if ($post_id && !empty($_POST['_wp_http_referer']) ) {  if (stripos($_POST['_wp_http_referer'],'wp-admin/post-new.php')!==false) { $post_name = slug_modify($new_slug); $_POST['post_name']=$post_name;} } 
    return $post_name;
//disable slug on any update
add_filter('wp_insert_post_data', 'myappend_slug', 3); function myappend_slug($dataaaaaa) { 
    if (!empty($_POST['_wp_http_referer'])) {
        if (stripos($_POST['_wp_http_referer'],'wp-admin/post-new.php')!==false) {
            $dataaaaaa['post_name']=slug_modify(     (!empty($_POST['post_name']) ? $_POST['post_name'] :$dataaaaaa['post_title'])      );
    return $dataaaaaa; 
function slug_modify($slg) {return str_replace('-','+',$slg);}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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