Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This question already has an answer here:

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.

If it helps, this is the site: http://www.denotenbalkers.be/fotos/

(As you can see, /fotos works, but the "Video's" link in the nav does not.)

EDIT 1 (22-4-2013)

I tried adding another cpt, but it gives the same problem: I can create a post with that type, but when I want to view it, I get a 404.

add_action( 'init', 'register_cpt_filmpje' );

function register_cpt_filmpje() {

    $labels = array( 
        'name' => _x( 'Filmpjes', 'filmpje' ),
        'singular_name' => _x( 'Filmpje', 'filmpje' ),
        'add_new' => _x( 'Voeg nieuw toe', 'filmpje' ),
        'add_new_item' => _x( 'Voeg nieuw filmpje toe', 'filmpje' ),
        'edit_item' => _x( 'Bewerk filmpje', 'filmpje' ),
        'new_item' => _x( 'Nieuw filmpje', 'filmpje' ),
        'view_item' => _x( 'Bekijk filmpje', 'filmpje' ),
        'search_items' => _x( 'Zoek filmpjes', 'filmpje' ),
        'not_found' => _x( 'Geen filmpjes gevonden', 'filmpje' ),
        'not_found_in_trash' => _x( 'Geen filmpjes in de prullenbak gevonden', 'filmpje' ),
        'parent_item_colon' => _x( 'Parent Filmpje:', 'filmpje' ),
        'menu_name' => _x( 'Filmpjes', 'filmpje' ),
    );

    $args = array( 
        'labels' => $labels,
        'hierarchical' => true,
        'description' => 'Gebruik dit posttype om filmpjes 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' => 'filmpjes',
            'with_front' => false,
            'feeds' => false,
            'pages' => true
        ),
        'capability_type' => 'page'
    );

    register_post_type( 'filmpje', $args );
}
share|improve this question
    
And your fotos CPT is registered exactly like that but with different text? –  s_ha_dum Apr 21 '13 at 15:11
    
@s_ha_dum Indeed. –  Bram Vanroy Apr 21 '13 at 15:11
    
When you edit a "video" there should be a "View CPT-Name" link. What is that URL? –  s_ha_dum Apr 21 '13 at 15:15
    
@s_ha_dum I'm sorry, I don't know where you want me to look. I had made this cpt before, and thus have some videos posted (ex. denotenbalkers.be/videos/2010-if-you-please-showavond) but the links are dead. –  Bram Vanroy Apr 21 '13 at 17:33
2  
If the same solution solves your question, it is essentially a duplicate. That’s not how I want to make my rep. :) I can give you your bounty back and close this question as duplicate if you agree. –  toscho May 4 '13 at 16:50
show 9 more comments

marked as duplicate by toscho May 4 '13 at 16:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

'with_front' => true says it should use the same settings as the post permalinks.

So when your posts permalinks are on /blog/%postname%/, the videos are on /blog/videos/.

share|improve this answer
    
Hm, strange. The other posttype (foto) has the same setting, and it does work on /fotos. But, I changed it to false and it's still not working. –  Bram Vanroy Apr 21 '13 at 9:53
    
If it helps, this is the site: denotenbalkers.be/fotos (As you can see, /fotos works, but the "Video's" link in the nav does not.) –  Bram Vanroy Apr 21 '13 at 9:58
add comment

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