WordPress.org

Forums

Custom page slug / modify default page slug? (2 posts)

  1. consolibyte
    Member
    Posted 5 years ago #

    I'm looking for a plugin which allows me to modify the default behavior of the page slugs.

    For instance, by default a page with "My Page Title" gets a page slug of "my-page-title". I need the *default* page slug to be "my_page_title" instead.

    Is there a plugin or way I can make this happen? Is it possible for me to write my own plugin, hooking into the slug-generation routine and making that happen?

  2. Will Kemp
    Member
    Posted 5 years ago #

    I guess you're talking about permalinks?

    If so, you can write a plugin that filters wp_insert_post_data . The field you need to modify is called post_name .

    I made a codex page for that filter hook:
    http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data - the information's taken from the comments in wp-includes/post.php and i haven't actually tried using it, so you may need to experiment a bit to get it to work.

    By the way, i believe it's not considered to be good practice to use underscores in URLs, although i can't remember why now!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags