custom post types - Trouble with CPT Child 404

I'm having issues with some custom post types showing up as 404's. I have a website i've been running fo

I'm having issues with some custom post types showing up as 404's. I have a website i've been running for about five years, that has a CPT called Videos, and a single PAGE which acts as the Videos main section.

websitename/videos

I now want to add some new PAGES to the end as a child of Video

websitename/videos/Newreleases

websitename/videos/latest

websitename/videos/example

(there are six of them in total)

The issue is that they show up as 404's. I've tried flushing the rewrite rules but that has not worked. The funny thing is one works just fine, but the rest are all 404s. They are not clashing with any taxonomies, they just wont work. I just don't understand the code enough to figure it out.

My code below

/ Videos Taxonomy

$labels = array(
    'name'                => 'Videos',
    'singular_name'       => 'Video',
    'menu_name'           => 'Videos',
    'name_admin_bar'      => 'Videos',
    'parent_item_colon'   => 'Parent Video',
    'all_items'           => 'All Videos',
    'add_new_item'        => 'Add Video',
    'add_new'             => 'Add Video',
    'new_item'            => 'New Video',
    'edit_item'           => 'Edit Video',
    'update_item'         => 'Update Video',
    'view_item'           => 'View Video',
    'search_items'        => 'Search Videos',
    'not_found'           => 'Nothing found',
    'not_found_in_trash'  => 'Nothing found in Trash',
);
$args = array(
    'label'               => 'Videos',
    'description'         => 'Videos',
    'labels'              => $labels,
    'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes', 'post-formats', ),
    'taxonomies'          => array( 'category', 'post_tag', 'videos' ),
    'hierarchical'        => false,
    'public'              => true,
    'show_ui'             => true,
    'show_in_menu'        => true,
    'menu_position'       => 13,
    'menu_icon'           => 'dashicons-video-alt3',
    'show_in_admin_bar'   => true,
    'show_in_nav_menus'   => true,
    'can_export'          => true,
    'has_archive'         => false,     
    'exclude_from_search' => false,
    'publicly_queryable'  => true,
    'capability_type'     => 'page',
);
register_post_type( 'videos', $args );

Does anyone know what i can do to fix this?

Any help would be hugely appreciated.

I'm having issues with some custom post types showing up as 404's. I have a website i've been running for about five years, that has a CPT called Videos, and a single PAGE which acts as the Videos main section.

websitename/videos

I now want to add some new PAGES to the end as a child of Video

websitename/videos/Newreleases

websitename/videos/latest

websitename/videos/example

(there are six of them in total)

The issue is that they show up as 404's. I've tried flushing the rewrite rules but that has not worked. The funny thing is one works just fine, but the rest are all 404s. They are not clashing with any taxonomies, they just wont work. I just don't understand the code enough to figure it out.

My code below

/ Videos Taxonomy

$labels = array(
    'name'                => 'Videos',
    'singular_name'       => 'Video',
    'menu_name'           => 'Videos',
    'name_admin_bar'      => 'Videos',
    'parent_item_colon'   => 'Parent Video',
    'all_items'           => 'All Videos',
    'add_new_item'        => 'Add Video',
    'add_new'             => 'Add Video',
    'new_item'            => 'New Video',
    'edit_item'           => 'Edit Video',
    'update_item'         => 'Update Video',
    'view_item'           => 'View Video',
    'search_items'        => 'Search Videos',
    'not_found'           => 'Nothing found',
    'not_found_in_trash'  => 'Nothing found in Trash',
);
$args = array(
    'label'               => 'Videos',
    'description'         => 'Videos',
    'labels'              => $labels,
    'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes', 'post-formats', ),
    'taxonomies'          => array( 'category', 'post_tag', 'videos' ),
    'hierarchical'        => false,
    'public'              => true,
    'show_ui'             => true,
    'show_in_menu'        => true,
    'menu_position'       => 13,
    'menu_icon'           => 'dashicons-video-alt3',
    'show_in_admin_bar'   => true,
    'show_in_nav_menus'   => true,
    'can_export'          => true,
    'has_archive'         => false,     
    'exclude_from_search' => false,
    'publicly_queryable'  => true,
    'capability_type'     => 'page',
);
register_post_type( 'videos', $args );

Does anyone know what i can do to fix this?

Any help would be hugely appreciated.

Share Improve this question asked May 4, 2020 at 18:29 Luke AllenLuke Allen 111 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

You can't have both a page and a Custom Post type with the same slug, in your case videos. See: https://core.trac.wordpress/ticket/38599 for a ticket recommending this be changed in core. A few solutions:

  • Change either the page or the post type to video instead of video

  • Follow the Template Hierarchy and create a archive-videos.php with the contents of your Video page.

  • Define a unique rewrite slug in the parameters for more details, as it does not support child pages.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744503006a4577542.html

相关推荐

  • custom post types - Trouble with CPT Child 404

    I'm having issues with some custom post types showing up as 404's. I have a website i've been running fo

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信