[英]Permalink with multiple custom post types (404 error)
I am trying to achieve a permalink structure with multiple custom post types inside of it. 我正在尝试实现具有多个自定义帖子类型的永久链接结构。 The first custom post type has a slug called 'service', the second custom post type has a slug called 'instructions'. 第一个自定义帖子类型具有称为“服务”的段,第二个自定义帖子类型具有称为“指令”的段。 The instructions post type needs to be after de service post type in the permalink. 在永久链接中,说明职位类型必须在服务职位类型之后。
The single page of the 'service' custom post type works, but I get a 404 page when trying to view the instructions page. “服务”自定义帖子类型的单个页面有效,但是当尝试查看说明页面时,我得到了404页面。
Examples: 例子:
domain.com/service (works, WordPress page) domain.com/service/service-1 (works, custom post type) domain.com/service/instructions (404, WordPress page) domain.com/service/instructions/instruction-1 (404, custom post type)
Where 'service' and 'instructions' are two different custom post types, 'instructions' is the single page of the 'instruction-1' custom post type. 其中“服务”和“指令”是两种不同的自定义帖子类型,“指令”是“ instruction-1”自定义帖子类型的单个页面。
My Custom post types: 我的自定义帖子类型:
'services' => array(
'slug' => 'service',
'supports' => array('title','editor'),
'internals' => array('Services','Services','All Services','Edit','Add'),
'menu' => true,
'public' => true,
'icon' => 'dashicons-admin-multisite',
'disableadd' => false
),
and 和
'instructions' => array(
'slug' => 'service/instructions',
'supports' => array('title','editor'),
'internals' => array('Instructions','Instructions','All instructions','Edit','Add'),
'menu' => true,
'public' => true,
'icon' => 'dashicons-admin-multisite',
'disableadd' => false
),
I Hope that my question is clear enough and that someone could help me. 我希望我的问题很清楚,希望有人可以帮助我。
thanks in advance! 提前致谢!
WordPress doesn't expect subfolder "a/c" slugs directly, while it can work implicitly for some time. WordPress不会期望子文件夹“ a / c”直接出现,但它可以隐式工作一段时间。 Slugs are expected to be one-level everywhere. 子弹在任何地方都应该是一级的。
Many plugins also expect it so there is a chance you will have problems with that later some day when you decide to use new plugin or update those you have. 许多插件也期望如此,因此当您决定使用新插件或更新自己拥有的插件时,有一天您可能会遇到问题。
So avoid that if you can. 因此,请尽可能避免这种情况。
Alternatively you may use unique one-level slug eg service_instructions at wordpress level, but create an internal rewrite of service/instructions/* -> service_instructions/* at .htaccess level. 或者,您可以使用唯一的一级子句,例如在wordpress级别使用service_instructions,但是在.htaccess级别创建service / instructions / *-> service_instructions / *的内部重写。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.