How can I get an url-friendly version of the post_title? I´m using anchor links for my posts on an archive page, and for the moment the posts get the post_ID as a hash tag but I would like to get the title instead as it would look nicer.
Leave a Reply
You must be logged in to post a comment.
PHP has a function for url encoding that would probably work:
If you want the short version with “-” between the words use the slug.
If you don’t want to use the slug use the function bellow:
https://codex.wordpress.org/Function_Reference/sanitize_title