generating post slug with info other than post title (4 posts)

  1. thatwastaxing
    Posted 4 years ago #

    I'm trying to set up a directory of people using custom post types and taxonomies.

    I've removed support for the title for the custom post type because I just want the user's display name to act as the title. Additionally, the user is limited to creating just 1 post of that type.

    The title is no problem, and easy enough for me to change in the template.

    However, upon publishing, the slug generated is something like "auto-draft-1" making the URL look like "http://localhost/mysite/mycustomposttype/auto-draft-1/"

    I'm trying to get it to be "http://localhost/mysite/mycustomposttype/username/" or "http://localhost/mysite/mycustomposttype/display-name/"

    I see that the slug generation happens upon publishing the post so I've looked into the wp_unique_post_slug function in wp-includes/post.php, lines 2800-2857, to see how it works but I'm out my depth here.

    Can anyone point me in the right direction?

  2. Justin Sternberg
    Posted 3 years ago #

    Looking for the same solution... Any luck?

  3. thatwastaxing
    Posted 3 years ago #

  4. Justin Sternberg
    Posted 3 years ago #

    I found this solution as well which was very helpful.


Topic Closed

This topic has been closed to new replies.

About this Topic