简体   繁体   中英

Wordpress rewrite rule with custom taxonomy and custom post type

I have custom post_type called 'video' and custom taxonomy "channels"

I want to rewrite my video details page like this:

http://example.com/funny/<postname>

here "funny" is channels term.

I tried some code like:

add_permastruct( 'video', '%channels%/%video%' );

It's working fine but when I'm trying to open post details page whose permalink structure is:

http://example.com/<parent_category>/<postname>

it's not working. All post single page show 404.

Please help me.

you should achive your result customizing the rewrite property on your post type definition:

Custom Post type id -> video

video Custom taxonomy id -> ct_video

Custom Post type id -> channels

channels custom taxonomy id -> ct_channels

if you want to customize your custom post type or cutom taxonomy archive or page:

'rewrite' => array('slug' => '[custom url]')

to personalize the url of your posts I advise you to download Custom Post Type Permalinks : https://wordpress.org/plugins/custom-post-type-permalinks/ and you can use it like this:

在此输入图像描述

defining the custom post type post url using the structure tags

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM