I am getting a 404 on my single custom post types whilst using the 'rewrite' option in the custom taxonomy. If I take the rewrite out the single page works but the custom taxonomy archive then 404's instead.
Here is the code for my custom post type;
/* Training Post Type */
function add_training_post_type() {
$labels = array(
'name' => _x('Training', 'post type general name'),
'singular_name' => _x('Training material', 'post type singular name'),
'add_new' => _x('Add Training','Training'),
'add_new_item' => __('Add new Training'),
'edit_item' => __('Edit Training'),
'new_item' => __('New Training'),
'all_items' => __('All Training'),
'view_item' => __('View Training'),
'search_items' => __('Search Training'),
'not_found' => __('No Training found'),
'not_found_in_trash' => __('No Training in Trash'),
'parent_item_colon' => '',
'menu_name' => __('Training')
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title')
);
register_post_type('training-and-events',$args);
flush_rewrite_rules();
}
add_action( 'init', 'add_training_post_type' );
And here's my code for the custom taxonomy;
/* Training Tax */
add_action( 'init', 'create_training_taxonomies', 0 );
function create_training_taxonomies()
{
$labels = array(
'name' => _x( 'Training categories', 'taxonomy general name' ),
'singular_name' => _x( 'Training category', 'taxonomy singular name' ),
'search_items' => __( 'Search Training categories' ),
'popular_items' => __( 'Popular Training categories' ),
'all_items' => __( 'All Training categories' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Edit Training category' ),
'update_item' => __( 'Update Training category' ),
'add_new_item' => __( 'Add Training category' ),
'new_item_name' => __( 'New Training category' ),
'menu_name' => __( 'Training categories' )
);
register_taxonomy('training-category',array('training-and-events'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array('slug' => 'training-and-events')
));
flush_rewrite_rules();
}
(The flush_rewrite_rules(); is just while I'm developing, I will remove once I have it working)
Does anyone know when I'm doing incorrectly here, I think I've got blindness as now that I have been staring at the code so long and it's feeling like spaghetti in my head ):
Thanks, Harry.