Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 ) );
}
share|improve this question
    
Hi, please embed all relevant code in the Question itself, you are free to edit it whenever needed. –  brasofilo Feb 7 '13 at 21:19
    
done. thank you for bringing this to my attention. –  Lukasz Feb 8 '13 at 16:08
add comment

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
    
ah, that worked. thanks! –  Lukasz Feb 7 '13 at 21:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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