Skip to:

Creating a slug from a string or title for part of link url

  • I am trying to create a link in the membership directory under each person’s name.
    You can see what I have so far at

    I did this by putting this code into the members-loop.php file.


    This grabs the name of the member’s profession from their profile data and uses is to create a link to a page that describes that profession. This works great except for one small problem:

    When the profession has 2 names such as “Naturopathic Doctor,” I need to turn this into a slug so that the link works. I have tried using the “sanitize_title_with_dashes()” function but it kept returning empty or doing nothing.

    How can I get the “Naturopathic Doctor” to read “naturopathic-doctor” inside the link?

    Thank you for any help,

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.