I’ve been working with custom post types for a little while now, but yesterday I took my first stab at a custom taxonomy to pair with them.
Here is my ‘company’ taxonomy:
function create_company_taxonomy() {
$labels = array(
'name' => _x( 'Companies', 'taxonomy general name' ),
'singular_name' => _x( 'Company', 'taxonomy singular name' ),
'search_items' => __( 'Search Companies' ),
'all_items' => __( 'All Companies' ),
'parent_item' => __( 'Parent Company' ),
'parent_item_colon' => __( 'Parent Company:' ),
'edit_item' => __( 'Edit Companies' ),
'update_item' => __( 'Update Companies' ),
'add_new_item' => __( 'Add New Company' ),
'new_item_name' => __( 'New Company Name' ),
'menu_name' => __( 'Company' ),
);
$args = array(
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'company' ),
'public' => true,
'hierarchical' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'query_var' => true,
'publicly_queryable' => true,
'capability_type' => 'post',
'hierarchical' => true,
'has_archive' => true
);
register_taxonomy( 'company', array( 'brochures','business-cards','post','websites' ), $args );
}
add_action( 'init', 'create_company_taxonomy', 0 );
As you can see I am trying to use it with ‘posts’ as well as three custom post types–‘brochures’,’business-cards’,’websites’
When I create a taxonomy-company.php template (based off archive.php) and give each of these post_types a term from the taxonomy, only posts display on the page. I cannot get the custom post types to display at all.
Do I need a custom query? Any insight would be appreciated.
EDIT: Here is one of my register_post_types as well
add_action( 'init', 'create_custom_post_types' );
function create_custom_post_types() {
$labels = array(
'name' => __( 'Websites' ),
'singular_name' => __( 'Website' )
);
$args = array(
'labels' => $labels,
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'websites'),
'taxonomies' => array( 'category','company','post_tag' ),
'supports' => array( 'title', 'editor', 'thumbnail' , 'custom-fields', 'excerpt' ),
'exclude_from_search' => true
);
register_post_type( 'websites', $args);
}