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.

I have few custom post type, on the single post of which i am getting 404 error page. I think i've tried almost every solutions posted on web but still it is not working for me and i've started to have a feeling that i have made some other mistake.As i try to debug i have found that each of my custom post have been parsed as 'attachments'. Please figure it out for me what mistake have i done.

function jnj_register_board_members_posttype ()
{

    $labels = array ( 
        'name' => _x ( 'Board Members' , 'jnj' ) , 
        'singular_name' => _x ( 'Board Member' , 'jnj' ) , 
        'add_new' => _x ( 'New Member' , 'jnj' ) , 
        'add_new_item' => __ ( 'New Board Member' , 'jnj' ) , 
        'edit_item' => __ ( 'Edit' , 'jnj' ) , 
        'new_item' => __ ( 'New Board Member ' ) , 
        'all_items' => __ ( 'All Board Members' ) , 
        'view_item' => __ ( 'View Board Member' ) , 
        'search_items' => __ ( 'Search Board Members' ) , 
        'not_found' => __ ( 'No Board Members found' ) , 
        'not_found_in_trash' => __ ( 'Board Member not found in Trash' ) , 
        'parent_item_colon' => '' , 
        'menu_name' => 'Board Member' )

    ;
    $args = array ( 
        'labels' => $labels , 
        'public' => true , 
        'publicly_queryable' => true , 
        'show_ui' => true , 
        'show_in_menu' => true , 
        'query_var' => true , 
        'rewrite' => array( 'slug' => 'board-members', 'with_front' => false),
        'capability_type' => 'post' , 
        'hierarchical' => false , 
        'menu_position' => 5 , 
        'menu_icon' => get_stylesheet_directory_uri ( ) . '/images/board-members.png' ,  
        'register_meta_box_cb'=>'register_board_members_metabox',
        'taxonomies' => array ( 'jnj_title' ) , 
        'supports' => array ( 'title' , 'editor' , 'thumbnail' , 'custom-fields' , 'excerpt' ) )
    ;

    register_post_type ( 'board_members' , $args );

}
add_action('init', 'jnj_register_board_members_posttype');
share|improve this question

1 Answer 1

Finally I found the solution myself.In case you are also having similar problem, add the following two lines

  global $wp_rewrite;
  $wp_rewrite->flush_rules(); 
share|improve this answer
    
Make sure you don’t flush the rules on every request, this is expensive. Visit the permalink settings once or add the flush to register_activation_hook. –  toscho Jan 2 '12 at 10:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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