• BramVanroy

    (@bramvanroy)


    I have created a custom post type “video” (see my functions.php below) and it should return an archive on mysite.com/video but instead I get a 404.

    **Functions.php**

    // Video's
        add_action( 'init', 'register_cpt_video' );
    
        function register_cpt_video() {
    
            $labels = array(
                'name' => _x( 'Video\'s', 'video' ),
                'singular_name' => _x( 'Video', 'video' ),
                'add_new' => _x( 'Voeg nieuwe toe', 'video' ),
                'add_new_item' => _x( 'Voeg nieuwe video toe', 'video' ),
                'edit_item' => _x( 'Bewerk video', 'video' ),
                'new_item' => _x( 'Nieuwe video', 'video' ),
                'view_item' => _x( 'Bekijk video', 'video' ),
                'search_items' => _x( 'Zoek video\'s', 'video' ),
                'not_found' => _x( 'Geen video\'s gevonden', 'video' ),
                'not_found_in_trash' => _x( 'Geen video\'s in de prullenbak gevonden', 'video' ),
                'parent_item_colon' => _x( 'Parent Video:', 'video' ),
                'menu_name' => _x( 'Video\'s', 'video' ),
            );
    
            $args = array(
                'labels' => $labels,
                'hierarchical' => true,
                'description' => 'Gebruik dit posttype om video\'s te posten',
                'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'page-attributes' ),
                'taxonomies' => array( 'post_tag' ),
                'public' => true,
                'show_ui' => true,
                'show_in_menu' => true,
                'menu_position' => 11,
    
                'show_in_nav_menus' => true,
                'publicly_queryable' => true,
                'exclude_from_search' => false,
                'has_archive' => true,
                'query_var' => true,
                'can_export' => true,
                'rewrite' => array(
                    'slug' => 'videos',
                    'with_front' => true,
                    'feeds' => true,
                    'pages' => true
                ),
                'capability_type' => 'page'
            );
    
            register_post_type( 'video', $args );
        }

    I am working with Buttercream as a parent theme.

    I have a similar cpt (“foto”) and that one does work flawlessly. Very strange. Is this a conflict with buttercream?

Viewing 1 replies (of 1 total)
  • Theme Author Caroline Moore

    (@sixhours)

    To rule out the theme, try activating one of the default themes.

    I’d try using a more specific post type name than “video” — that’s very general and could be interfering with another WordPress global variable, plugin, or function somewhere. Video post format comes to mind.

Viewing 1 replies (of 1 total)
  • The topic ‘Custom post type archive does not work’ is closed to new replies.