具有自定义分类和自定义帖子类型的Wordpress重写规则

Vis*_*mal 5 php wordpress url-rewriting

我有名为“视频”的自定义post_type和自定义分类法“渠道”

我想这样重写我的视频详细信息页面:

http://example.com/funny/<postname>
Run Code Online (Sandbox Code Playgroud)

这里的“搞笑”是渠道术语。

我尝试了一些代码,例如:

add_permastruct( 'video', '%channels%/%video%' );
Run Code Online (Sandbox Code Playgroud)

它工作正常,但是当我尝试打开永久链接结构为的帖子详细信息页面时:

http://example.com/<parent_category>/<postname>
Run Code Online (Sandbox Code Playgroud)

它不起作用。所有帖子单页显示404。

请帮我。

fab*_*bio 0

您应该在帖子类型定义上自定义重写属性来实现结果:

自定义帖子类型 ID ->视频

视频自定义分类 ID -> ct_video

自定义帖子类型 ID ->频道

频道自定义分类 ID -> ct_channels

如果您想自定义自定义帖子类型或自定义分类存档或页面:

'rewrite' => array('slug' => '[custom url]')
Run Code Online (Sandbox Code Playgroud)

要个性化您的帖子的网址,我建议您下载自定义帖子类型永久链接https://wordpress.org/plugins/custom-post-type-permalinks/ ,您可以像这样使用它:

在此输入图像描述

使用结构标签定义自定义帖子类型帖子 url