WordPress.org

Ready to get started?Download WordPress

Forums

Custom Parmalink Structure (11 posts)

  1. suvosaha
    Member
    Posted 3 years ago #

    Hello Experts,

    I've an issue with my wordpress blog permalink. My Permalink structure is like this: http://mysearchpage.org/my-test-page-permalink

    But i want the permalink like this:http://mysearchpage.org/my_test_page_permalink

    I've tried the permalink option present in my dashboard but it doesn't work. Any help??

    Thanks in advance.

  2. Joseph
    Member
    Posted 3 years ago #

    Try adding this to your functions.php

    add_filter( 'sanitize_title', 'dashes_to_underscore' );
    function dashes_to_underscore( $title ){
        return str_replace( '-', '_', $title );
    }

    Ref: http://stackoverflow.com/questions/1728300/how-do-i-use-underscore-in-a-wordpress-permalink

  3. suvosaha
    Member
    Posted 3 years ago #

    I think i need to change my Function.php again after i upgrade to newer versions. Right? Is there any permanent solutions?

  4. Joseph
    Member
    Posted 3 years ago #

    Only if you update/change theme. Updating WordPress does not affect your functions.php.

  5. suvosaha
    Member
    Posted 3 years ago #

    Not working :( Getting that line at the top of Header

  6. Joseph
    Member
    Posted 3 years ago #

    Can you provide more detail? Getting what line?

    Something I should have mentioned is that block of code only convert hyphens to underscores for new posts/pages. To convert existing ones, you'll need to run the following SQL in phpmyadmin:

    UPDATE wp_posts SET post_name = replace(post_name, '-', '_');

    Make sure to backup your database before running it just in case something goes wrong.

  7. suvosaha
    Member
    Posted 3 years ago #

    See this website. I'm testing this here: http://cidoc.info/

  8. Joseph
    Member
    Posted 3 years ago #

    Where did you place it? It should be inside functions.php anywhere between the first and last line (between <?php and ?>).

  9. suvosaha
    Member
    Posted 3 years ago #

    yah between php

  10. Joseph
    Member
    Posted 3 years ago #

    If it's in the right place then it shouldn't display as text unless you've printed/echoed it.

  11. suvosaha
    Member
    Posted 3 years ago #

    Yah It's working Now. Thanks for your help :)

Topic Closed

This topic has been closed to new replies.

About this Topic