简体   繁体   English

具有多种自定义帖子类型的永久链接(404错误)

[英]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.

相关问题 使用 add_permastruct 返回常规帖子错误/404 的多个自定义 post_type URL 的自定义永久链接结构 - Custom permalink structure for multiple custom post_type URLs using add_permastruct returning regular posts error / 404 自定义帖子类型和页面层次结构-错误404 - Custom post types & Pages hierarchy - Error 404 初学者:如何将永久链接添加到WP_Query多个自定义帖子类型? - Beginner: How to add permalink to WP_Query multiple custom post types? WordPress 分页链接在自定义帖子类型上返回 404 错误(仅限)? - WordPress pagination links return 404 error on custom post types (only)? 在自定义帖子类型中使用元值追加/添加永久链接 - Append/prepend permalink with meta values in custom post types Wordpress 帖子名称固定链接 nginx 显示 404 错误 - Wordpress post name permalink with nginx show 404 error Wordpress - 自定义帖子类型和自定义永久链接结构错误 - Wordpress - Custom Post Type and Custom Permalink Structures Error WordPress主页自定义帖子类型分页404 - Wordpress homepage Custom Post types pagination 404 自定义帖子类型永久链接返回 404 - Custom post types permalinks returning 404 如何在 WordPress URL 结构中的自定义帖子固定链接中添加多个分类 - How to Add Multiple Taxonomies in Custom Post Permalink in WordPress URL structure
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM