I can’t seem to get archive page or category page to work correctly.

I am following http://codex.wordpress.org/Template_Hierarchy#Category_display

and it still defaults to archive.php ( i think, according to chart ) even though I have named it category-business.php

here is my code:

/******************
//  Business
******************/

function my_custom_post_business() {
  $labels = array(
        'name'               => _x( 'business', 'post type general name' ),
        'singular_name'      => _x( 'business', 'post type singular name' ),
        'add_new'            => _x( 'Add New', 'book' ),
        'add_new_item'       => __( 'Add New business' ),
        'edit_item'          => __( 'Edit business' ),
        'new_item'           => __( 'New business' ),
        'all_items'          => __( 'All business' ),
        'view_item'          => __( 'View business' ),
        'search_items'       => __( 'Search business' ),
        'not_found'          => __( 'No business found' ),
        'not_found_in_trash' => __( 'No business found in the Trash' ), 
        'parent_item_colon'  => '',
        'menu_name'          => 'business'
    );
    $args = array(
        'labels'        => $labels,
        'description'   => 'Holds our business and business specific data',
        'public'        => true,
        'hierarchical'      => true,
        'show_ui'           => true,
        'show_in_nav_menus' => true,
        'menu_position' => 5,
        'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
        'has_archive'   => true,

        //'taxonomies' => array('category'),
    );
    register_post_type( 'business', $args );

}
add_action( 'init', 'my_custom_post_business' );



/** add categories for custom post type */
add_action( 'init', 'build_taxonomies', 0 );
function build_taxonomies() {
    register_taxonomy( 'mycategories', 'business', array( 'hierarchical' => true, 'label' => 'Business Categories', 'query_var' => true, 'rewrite' => true ) );
}

2 Answers
2

Since you are using a custom taxonomy and not the native post categories you need to name your file taxonomy-{taxonomy}.php and in your case it would be
taxonomy-mycategories.php

Take a look at the section of the template hierarchy to display custom taxonomy archives.

Leave a Reply

Your email address will not be published. Required fields are marked *