Hi guys,
I created a custom post type with taxonomy now the proble is in my taxonomy area i add some categories and after that i assigned posts on those categories.
Taxonomy name: Sections In sections: Articles, Interview, Case Studies
Now posts are assigned properly and single post showing properly but the problem is when i click on Sections>articles or interviews or castudies to view my all pubslish post under these categories then it redirect to 404 page.
i am working hard but not found any solution for that.
Here is my Code:
add_action('init', 'avanza_tech_page_register');
function avanza_tech_page_register() {
$labels = array(
'name' => _x( 'Techronicle', 'post type general name' ),
'singular_name' => _x( 'Avanza Techronicle Page', 'post type singular name' ),
'add_new' => __( 'Add New Page' ),
'add_new_item' => __( 'Add New Page' ),
'edit_item' => __( 'Edit Page' ),
'new_item' => __( 'New Page' ),
'view_item' => __( 'View Page' ),
'search_items' => __( 'Search Pages' ),
'not_found' => __( 'No pages found.' ),
'not_found_in_trash' => __( 'No pages found in Trash.' ),
'menu_name' => __( 'Techronicle' ),
);
$args = array(
'labels' => $labels,
'description' => 'Avanza Solutions.',
'public' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'show_ui' => true,
'menu_position' => 22,
'menu_icon' => get_bloginfo('template_directory') . '/images/wp_avanza_icon.png',
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => true,
//'taxonomies' => array('category', 'post_tag', 'class'),
'rewrite' => array( 'slug' => 'Techronicle','with_front' => true),
'query_var' => true,
'can_export' => true,
'show_in_nav_menus' => true,
'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'post-formats'),
);
register_post_type('avanza_tech_page', $args);
flush_rewrite_rules();
}
add_action( 'init', 'register_taxonomy_sections' );
function register_taxonomy_sections() {
$labels = array(
'name' => _x( 'Sections', 'sections' ),
'singular_name' => _x( 'Sections', 'sections' ),
'search_items' => _x( 'Search', 'sections' ),
'popular_items' => _x( 'Popular', 'sections' ),
'all_items' => _x( 'All', 'sections' ),
'parent_item' => _x( 'Parent', 'sections' ),
'parent_item_colon' => _x( 'Parent:', 'sections' ),
'edit_item' => _x( 'Edit', 'sections' ),
'update_item' => _x( 'Update', 'sections' ),
'add_new_item' => _x( 'Add New', 'sections' ),
'new_item_name' => _x( 'New', 'sections' ),
'separate_items_with_commas' => _x( 'Separate with commas', 'sections' ),
'add_or_remove_items' => _x( 'Add or remove sections', 'sections' ),
'choose_from_most_used' => _x( 'Choose from the most used sections', 'sections' ),
'menu_name' => _x( 'Sections', 'sections' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_tagcloud' => true,
'hierarchical' => false,
// 'rewrite' => array('slug' => 'sections', 'with_front' => true),
//'rewrite' => array( 'hierarchical' => true ),
// 'rewrite' => true,
'rewrite' => array( 'hierarchical' => true ),
//'rewrite' => array('sections' => true ),
'query_var' => true,
//'rewrite' => array( 'slug' => 'sections' )
);
register_taxonomy( 'sections', array('avanza_tech_page'), $args );
}
:s
Guys i also have:
avanza_tech_page.php — Main Page
single-avanza_tech_page.php — Single Post page
taxonomy-sections.php — Not working 
Try 'rewrite' => false, and see if it works. Just for testing. Maybe here is the problem.
Smartik said
Try'rewrite' => false,and see if it works. Just for testing. Maybe here is the problem.
Mate no success yet 
just visit your Settings > Permalinks page.
itsmattadams saidOMG its now working when i made comment flush_rewrite and with @Smartik suggestion rewrite false.
just visit your Settings > Permalinks page.
register_post_type('avanza_tech_page', $args);
//flush_rewrite_rules();
}
But the urls formate changed: ?sections=articles
rather than /sections/articles or just /articles
seems permalink issue i again save permalinks but not success.
Visiting the permalinks page also flushes the rewrite rules.
Set this to false to use “pretty permalinks”.
'rewrite' => array('slug' => 'sections', 'with_front' => false)itsmattadams said
Visiting the permalinks page also flushes the rewrite rules.Set this to false to use “pretty permalinks”.
'rewrite' => array('slug' => 'sections', 'with_front' => false)
WAOn with your help its working, And also 1 thing that i also was doing wrong its i am using flush_rewrite functions in register post_type now i move the flush_rewrite in register_taxonomy and now its working fine 
Thankyou Smartik and itsmattadams. Great Authors.
I wouldn’t go adding flush_rewrite anywhere. Just have your user re-saver their permalink settings upon theme activation.
WPExplorer said
I wouldn’t go adding flush_rewrite anywhere. Just have your user re-saver their permalink settings upon theme activation.
So What it will be the best way.
