1661 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

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

1661 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

Guys i also have:

avanza_tech_page.php Main Page single-avanza_tech_page.php Single Post page taxonomy-sections.php Not working :(

1272 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $40,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 50+ items on Envato Market
+5 more
Smartik says

Try 'rewrite' => false, and see if it works. Just for testing. Maybe here is the problem.

1661 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

Try 'rewrite' => false, and see if it works. Just for testing. Maybe here is the problem.

Mate no success yet :(

709 posts
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+2 more
ChillThemes says

just visit your Settings > Permalinks page.

1661 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

just visit your Settings > Permalinks page.
OMG its now working when i made comment flush_rewrite and with @Smartik suggestion rewrite false.
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.

709 posts
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+2 more
ChillThemes says

Visiting the permalinks page also flushes the rewrite rules.

Set this to false to use “pretty permalinks”.

'rewrite' => array('slug' => 'sections', 'with_front' => false)
1661 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

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.

401 posts
  • Located in United States
  • Power Elite Author: Sold more than $1M on Envato Market
  • Has sold $1M+ on Envato Market and is now a Power Elite Author
  • Made it to the Authors' Hall of Fame
+4 more
WPExplorer says

I wouldn’t go adding flush_rewrite anywhere. Just have your user re-saver their permalink settings upon theme activation.

1661 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

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.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by