535 posts
  • Exclusive Author
  • Sold between 50 000 and 100 000 dollars
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Portugal
plusquare says

Hey guys,

I could use some help here. So I have a custom post type portfolio and an archive-portfolio.php file with /* Template Name: Portfolio */ on the header. Does this prevent wordpress from choosing this file for displaying categories, it works good when I add a normal portfolio page but when I try to go to a category it goes for archive.php instead.

I’ve already tried to remove template name but still it doesn’t work, and yes I have

'has_archive' => true

in the post type register :S

Thanks for any help guys

579 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 10 000 and 50 000 dollars
ChapterThemes says

Is the post type also exactly registered with the name ‘portfolio’ ?

The template file needs the extact name of the post type, including prefixes

535 posts
  • Exclusive Author
  • Sold between 50 000 and 100 000 dollars
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Portugal
plusquare says

Thanks for your reply, yes here’s the post type register:

register_post_type( 'portfolio' , array(
        'label'=>_x('Portfolio','Type','pqportfolioposttype'),
        'description'=>__('Special type of post for creating work','pqportfolioposttype'),
        'labels' => $labels,
        'public' => true,
        'menu_position' => 5,
        'show_ui' => true,
        'show_in_menu' => true,
        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'query_var' => true,
        //'menu_icon'=>get_stylesheet_directory_uri() . '/images/portfolio_icon.png',
        'rewrite' => array("slug" => "portfolio"), // Permalinks format
        'capability_type' => 'post',
        'hierarchical' => false,
        'has_archive' => true,
        'supports' => array( 'title')
        )
      ); 
535 posts
  • Exclusive Author
  • Sold between 50 000 and 100 000 dollars
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Portugal
plusquare says

And the taxonomy:

$taxonomy_portfolio_category_args = array(
    'labels' => $taxonomy_portfolio_category_labels,
    'public' => true,
    'show_in_nav_menus' => true,
    'show_admin_column' => true,
    'show_ui' => true,
    'show_tagcloud' => true,
    'hierarchical' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'portfolio_category' )
);
register_taxonomy( "portfolio_category", array("portfolio"), $taxonomy_portfolio_category_args);

Any help would be amazing :S

707 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 10 and 49 items
  • Has been a member for 5-6 years
  • Exclusive Author
  • Microlancer Beta Tester
ChillThemes says

Copy archive.php and rename it to taxonomy-portfolio_category.php

535 posts
  • Exclusive Author
  • Sold between 50 000 and 100 000 dollars
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Portugal
plusquare says

Thanks so much for you answer that got it to work :)

Cheers

707 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 10 and 49 items
  • Has been a member for 5-6 years
  • Exclusive Author
  • Microlancer Beta Tester
ChillThemes says

You’re welcome, happy theming.

by
by
by
by
by
by