1

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.

1 Answer 1

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.org/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.
4
  • You say I can't, but I do. I have this structure for five different custom post types. Each CPT has a separate page, which all work fine. The issue i'm having is with the children of this page. I know it works, because one of them does, but I'm looking for solutions to fix the rest.
    – Luke Allen
    May 5, 2020 at 8:28
  • It may be working but it's not the way that WordPress is designed to work. That trac ticket is suggesting a change but your setup seems to be working using a workaround. You mention children pages, can you clarify if you are creating chld pages of the videos page or are you referring to the posts themselves as children? You won't be able to have children pages of the videos page. I would suggest using the methods I suggest to avoid further issues down the line.
    – Brooke.
    May 5, 2020 at 16:03
  • Thanks for replying. I'm trying to create a child of the VIDEO page. Not the posts themselves. Changing the format now would considerable break the site, so changing it is not an option.
    – Luke Allen
    May 5, 2020 at 18:35
  • Due to the nature of how WordPress' permalink structure works, it's not going to be possible to have a post type slug and a page (with child pages) share the same slug. You might be able to do some workaround, but I would strongly encourage utilizing another solution.
    – Brooke.
    May 5, 2020 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.