[英]Is it Possible to Change a Custom Post Type Permalink Structure to Use %post_id% instead of %postname%?
For whatever reason, this seemingly simple task is causing some issues for me. 无论出于什么原因,这个看似简单的任务都会给我带来一些问题。
I have a custom post type with a permalink structure similar to this: 我有一个自定义帖子类型,其永久链接结构类似于此:
http://mywebsite.com/projects/the-name-of-my-project/
However, I want something like this: 但是,我想要这样的东西:
http://mywebsite.com/projects/52418/
Were this a regular old post and not a custom post type, I would simply setup my permalink structure as: 如果这是常规的旧帖子,而不是自定义的帖子类型,我只需将我的永久链接结构设置为:
/projects/%post_id%/
But because it's a custom post type, the method has eluded me. 但是因为它是自定义帖子类型,所以该方法使我难以理解。
Any ideas are much appreciated. 任何想法都非常感谢。
Thanks! 谢谢!
Check out the following page about register_post_type
查看有关register_post_type
的以下页面
http://codex.wordpress.org/Function_Reference/register_post_type http://codex.wordpress.org/Function_Reference/register_post_type
Consider reading this segement: permalink_epmask
and rewrite
. 考虑阅读以下内容: permalink_epmask
和rewrite
。 This have enough code example. 这有足够的代码示例。
I am not in the favour of installing plugin for a small task. 我不赞成为小任务安装插件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.