I'm trying to make a blog script from scratch (PHP) and import posts from Wordpress. I need to use the exact same permalink algorithm as Wordpress because I want to keep the URLs same. (and just in case I need to go back to Wordpress)
The custom structure is /%postname%/. I noticed that special characters (such as * - /) and un开发者_如何学Goicode characters are ignored, and if it's a duplicate, a number is automatically added at the end. Is that all I need to know?
Thanks.
The Wordpress function you need to look at is sanitize_title_with_dashes
in wp-includes/formatting.php
.
WordPress has defaults, but those defaults may change from version to version. Plus WordPress also lets you customize the permalinks, so I don't think you'll find a "universal" structure.
With that in mind though, here's an article on URL Design that might be helpful.
精彩评论