we have set up a custom post type under the heading of custom post type along w/two custom taxonomies. (the following code has been added to our functions.php page:)
add_action(‘init’, ‘create_seminar_post_type’);
function create_seminar_post_type(){
register_post_type(‘seminars’,
array(
'labels'=> array(
'name' => 'Seminars',
'singular_name' => 'Seminar',
'add_new' => 'Add New Seminar',
'add_new_item' => 'Add New Seminar',
'edit' => 'Edit Seminars',
'edit_item' => 'Edit Seminar',
'new_item' => 'New Seminar',
'view' => 'View Seminar',
'view_item' => 'View Seminar',
'search_items' => 'Search Seminars',
'not_found' => 'No Seminars found',
'not_found_in_trash' => 'No Seminars found in Trash',
'parent' => 'Parent Seminar',
),
'supports' => array('title', 'editor', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'thumbnail', 'author', 'page-attributes'),
'public' =>true,
'taxonomies' => array('post_tag', 'category')
)
);
register_taxonomy ('trt', 'seminars', array(
'labels' =>array(
'name' =>'Total Running Time',
'singular_name' => 'Total Running Time',
'search_items' => 'Search Total Running Time',
'popular_items' => 'Popular Total Running Times',
'all_items' => 'All Running Times',
'parent_item' => 'Parent Running Time',
'edit_item' => 'Edit Running Time',
'update_item' => 'Update Running Time',
'add_new_item' => 'Add New Running Time',
'new_item_name' => 'New Running Time Name'
),
'hierarchical' => true, 'label' => 'Total Running Time'));
register_taxonomy ('discs-in-set', 'seminars', array(
'labels' =>array(
'name' =>'# of Discs in Set',
'singular_name' => 'Total Discs in Set',
'search_items' => 'Search Discs in Set',
'popular_items' => 'Popular Discs in Set',
'all_items' => 'All Discs in Set',
'parent_item' => 'Parent Discs in Set',
'edit_item' => 'Edit Discs in Set',
'update_item' => 'Update Discs in Set',
'add_new_item' => 'Add New Discs in Set',
'new_item_name' => 'New Discs in Set'
),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'query_var' => 'discs-in-set',
'show_tagcloud' => true,
));
}
and here’s the code added w/the loop in our single-seminar page (derived from the single.php page):
<?php $loop = new WP_Query( array( 'post_type' => 'seminars', 'posts_per_page' => 10 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php the_title( '<h2 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h2>' ); ?>
what we’d like to have shown for each individual seminar is the seminar info, along w/the custom taxonomy info of running time and discs in set. But all that shows is the seminar post and its accompanying categories & tags. what should I do to make this work?
on a similar note, when viewing the seminars listing in the dashboard, it shows all the listings , with columns for title, author, categories, tags, comments and date. It would be nice to incorporate the custom taxonomies into this listing for the sake of simplicity. Can this be done w/custom taxonomies? Or is there a more direct mode in doing this? any help/insights are greatly appreciated..
- don
For the dashboard post listing bit….
http://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column
I use this to add in 2 columns to my ve_products custom post type. the description column displays the excerpt, the prod_cat displays my custom taxonomy (product_category). Getting rid of:
Would kill the excerpt portion and only bring in the taxonomy. You just have to swap in your own tax name. And also in the first filter, your own CPT (per the link I gave)
As for your other question, are you just looking to spit out the taxonomy? I’m not sure, so I will just try to answer what I think you are asking.
I use this to store my taxonomy (product_category). I put this up at the top of my loop, above where I need to display the actual tax. Then I can spit it out using:
So the big block of code loads up the terms for product_category, and then echoing out taxo text spits out the terms, it behaves like the_category would. You would just need to swap in your tax name where I have product_category