Ready to get started?Download WordPress


using underscores in %postname% (4 posts)

  1. Liz
    Posted 9 years ago #

    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.

  2. carthik
    Posted 9 years ago #

    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.

  3. Liz
    Posted 9 years ago #

    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.

  4. carthik
    Posted 9 years ago #

    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 '_'

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.