Support » Installing WordPress » using underscores in %postname%

  • Is there any way to modify the code so that %postname% uses underscores rather than dashes? I’d rather not have to deal with mod_rewrite or redirects if I don’t have to–seems like it makes more sense to modify the code itself to simply use underscores.
    I’m not a PHP wizard, but I’m competent with it…I’m just not sure where to find the escape function that’s apparently being used.

Viewing 3 replies - 1 through 3 (of 3 total)
  • There is a function called sanitize_title. That can be modified to do what you want done.
    – is better than _ , as far as google and some other search engines are considered, cause they properly seperate words. Moving over to the – style might be better for you in the bigger scheme of things.

    Thanks for the quick response!
    I’ve debated that a bit. I may eventually shift over to dashes (and lose the .php extension I now use), but I feel like there’s enough change in my blogging world right now and the underscores provide some sense of continuity.
    And since I haven’t had much trouble with Google finding my posts up ’til now (the full post name is still in the post itself…), I’m not too worried.

    Okay Kiz, the function sanitize_title() is in wp-includes/functions-formatting.php
    you’ll need to change these line there…

    85 $title = str_replace(' ', '-', $title);
    86 $title = preg_replace('|-+|', '-', $title);

    changing ‘-‘ to ‘_’

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘using underscores in %postname%’ is closed to new replies.