Vote count:
0
So, I've seen a ton of "solutions" on this site, but none of them seem to work fully for me. I would like to strip all punctuation from a post name so that the system can dynamically create urls for each post. I found an article by David Walsh that provides a step by step tutorial on how this can be achieved. However, not everything gets stripped. Here is a link to the article (just in case): http://ift.tt/1gW9W2j.
Here's the code I've altered to remove all punctuation:
$return = trim(preg_replace('/[^a-z0-9]+/i'," ", strtolower($post_name)));
Here's an example post name: Testing's, this & more!
Results when I echo the url: testing-039-s-this-amp-more.php
I'm not sure why it's keeping the html code for the ampersand and the single quote. Any ideas?!?
asked 1 min ago
Aucun commentaire:
Enregistrer un commentaire