1

I created a custom post type using following code:

add_action( 'init', 'create_team_post_type' );
function create_team_post_type() {
  register_post_type( 'portfolio',
    array(
      'labels' => array(
        'name' => __( 'Portfolio' ),
        'singular_name' => __( 'Portfolio' )
      ),
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'menu_position' => null,
        'taxonomies' => array('portfolio_category'),
        'supports' => array('title','editor','thumbnail')
    )
  );
}

and taxonomy using following code:

function taxonomies_portfolio() {
    $labels = array(
        'name'              => _x( 'Portfolio categories', 'taxonomy general name' ),
        'singular_name'     => _x( 'Portfolio categories', 'taxonomy singular name' ),
        'search_items'      => __( 'Query portfolio categories' ),
        'all_items'         => __( 'All portfolio categories' ),
        'parent_item'       => __( 'Parent category' ),
        'parent_item_colon' => __( 'Parent category:' ),
        'edit_item'         => __( 'Edit portfolio category' ), 
        'update_item'       => __( 'Update portfolio category' ),
        'add_new_item'      => __( 'Add Edit portfolio category' ),
        'new_item_name'     => __( 'New portfolio category' ),
        'menu_name'         => __( 'Categories' ),
    );
    $args = array(
        'labels' => $labels,
        'hierarchical' => true,
        'rewrite' => true
    );
    register_taxonomy( 'portfolio_category', 'portfolio', $args );
}

add_action( 'init', 'taxonomies_portfolio', 0 );

When I click on category that is navigating to index.php. I created a file name called taxnomy-portfolio_category.php. The URL is showing url/taxnomy-portfolio_category.php/cat_name but the result is index.php.

4
  • Really, taxnomy?
    – fuxia
    Feb 17 '17 at 7:23
  • yes.I need template how to display categories.
    – Mr.Pandya
    Feb 17 '17 at 7:27
  • Try the correct name with taxonomy.
    – fuxia
    Feb 17 '17 at 7:29
  • taxonomy in there but not redirecting.Can youu help me
    – Mr.Pandya
    Feb 17 '17 at 7:32
1

The hierarchy for a custom taxonomy is listed below:

taxonomy-{taxonomy}-{term}.php: For example, if the taxonomy is named “sometax,” and the taxonomy’s term is “someterm,” WordPress would look for a file named taxonomy-sometax-someterm.php.

taxonomy-{taxonomy}.php: For example, if the taxonomy is named “sometax,” WordPress would look for a file named taxonomy-sometax.php

taxonomy.php

archive.php

index.php

url:

/you_site.com/portfolio_category/term_name

Provided that the settings Admin -> Settings -> Permalinks found:

/%category%/%postname%.html
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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