WordPress custom post type uses frontpage

EDIT Please ignore this topic. The problem turend out not to be related to wordpress or permalinks at all, but came from a stupid voeding mistrals.

I’ve defined a wordpress custom post type as followed:

Read More
add_action('init', 'fotoalbums_register_posttype');  
function fotoalbums_register_posttype() {  
register_post_type( 'fotoalbum-item' , array(  
    'labels' => array(
                'name'          => 'Fotoalbums',
                'singular_name' => 'Fotoalbum',
                'menu_name'     => 'Fotoalbums',
                'all_items'     => 'Overzicht',
                'add_new'       => 'Nieuw album',
                'add_new_item'  => 'Nieuw album',
                'edit_item'     => 'Bewerk album',
                'new_item'      => 'Nieuw album',
                'view_item'     => 'Bekijk album',
                'search_items'  => 'Zoek albums',
                'not_found'     => 'Niet gevonden',         
    ),  
    'public' => true,  
     'has_archive' => false,
    'show_ui' => true,  
    'capability_type' => 'page',  
    'hierarchical' => false,   
    'supports' => array('title', 'editor') ,
     'menu_position' => 31,
     'rewrite' => array( 'slug' => 'fotoalbum', 'with_front' => true)
   )//end array
); //end register_post_type()
}//end function fotoalbums_register_posttype()  

Then I created a page called single-fotoalbum-item.php which is supported to display a single item of this post type.
Strange thing is, it does not. Probabply something to do with permalinks, because:

the_permalink(); gives http://kdans.net/e-motion-2012/ and results in a 404 error

the permalink in wp-admin shows http://kdans.net/fotoalbum/e-motion-2012/ , which displays the
frontpage template (!!)

I did reserved permalinks multiple times, but some who this problem keeps returning. Where’s my mistake?

As did suggested in the comments, here are the rewrite rules.

http://kdans.net/fotoalbum/e-motion-2012/ gives:
index.php?fotoalbum-item=$matches[1]&page=$matches[2] (source fotoalbum-item)
index.php?pagename=$matches[1]&page=$matches[2] (source: page)
index.php?attachment=$matches[1] (source: post)

http://kdans.net/e-motion-2012/ gives
index.php?pagename=$matches[1]&page=$matches[2] (source: page)
index.php?name=$matches[1]&page=$matches[2] (source: post)

Related posts

Leave a Reply

3 comments

  1. I think the problem is here : 'rewrite' => array( 'slug' => 'fotoalbum', 'with_front' => true)

    So when a rewrite is occurred it change from fotoalbum-item to fotoalbum. So that’s why the url is http://kdans.net/fotoalbum/e-motion-2012/ and not http://kdans.net/fotoalbum-item/e-motion-2012/

    So you create the custom post and when you did the first rewrite ie from the Setting->Permalinks it changed the slug to fotoalbum.

    Try to change it to : 'rewrite' => array( 'slug' => 'fotoalbum-item', 'with_front' => true) and reflush the permalinks. It should be work.