永久链接有通用算法吗? (人类可读)
我正在尝试从头开始制作博客脚本(PHP)并从 Wordpress 导入帖子。 我需要使用与 WordPress 完全相同的永久链接算法,因为我想保持 URL 相同。 (以防万一我需要返回 WordPress)
自定义结构是 /%postname%/。 我注意到特殊字符(例如 * - /)和 unicode 字符会被忽略,如果重复,则会在末尾自动添加一个数字。 这就是我需要知道的全部吗?
谢谢。
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 unicode 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要查看的 WordPress 函数是
中的
。sanitize_title_with_dashes
wp-includes/formatting.phpThe Wordpress function you need to look at is
sanitize_title_with_dashes
inwp-includes/formatting.php
.WordPress 有默认值,但这些默认值可能会因版本而异。另外,WordPress 还允许您自定义永久链接,因此我认为您不会找到“通用”结构。
考虑到这一点,这里有一篇关于 URL 设计 的文章可能会有所帮助。
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.