Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Add Category Column & Filter a Custom Post Type WordPress

  • SOLVED

I have set up a custom post type in WP 3.1 following code which works:
function gwd_post_type_business() {
register_post_type( 'business',
array(
'label' => __('Businesses'),
'public' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'rewrite' => true,
'hierarchical' => true,
'menu_position' => 5,
'supports' => array(
'title',
'editor',
'thumbnail',
'excerpt',
'custom-fields',
'revisions')
)
);
register_taxonomy('businesscat', 'business', array('hierarchical' => true, 'label' => __('Business Categories'), 'singular_name' => 'Category'));
}
add_action('init', 'gwd_post_type_business');


<strong>Question 1</strong>
I require the code to create a column in my admin view of the business posts that lists the category or categories that are ticked for each post.

<strong>Question 2</strong>
I require coding to create a drop down filter in my admin view that lists the categories so I can filter by category.

<strong>Requirements</strong>
What I am after is pretty much identical to the default posts categories list and filtering system standard with WP.
However I require it for my Custom Post Type.
I require the full coding that I can just cut and paste into my theme-init.php file.

Answers (2)

2011-03-04

Oleg Butuzov answers:

if you can encrease prize to 25 i can help you =)


parksey18 comments:

$25 it is.


Oleg Butuzov comments:

work start... timer on.


Oleg Butuzov comments:

sebastien... its already done and sent...


Oleg Butuzov comments:

Few hours ago...


parksey18 comments:

Cheers Oleg, thanks for the prompt and thorough code.

2011-03-04

Sébastien | French WordpressDesigner answers:

QUESTION 1 :

// ADDS EXTRA INFO TO ADMIN MENU FOR BUSINESSCAT POST TYPE
add_filter("manage_edit-business_columns", "slh_edit_columns");
add_action('manage_business_posts_custom_column', "slh_custom_columns");

function slh_edit_columns( $columns ) {
$columns['business_cat'] = "Category";
$columns['description'] = "decription";

return $columns;
}

function slh_custom_columns( $column ) {
global $post;
switch( $column ) {
case "description":
the_excerpt();
break;
case "business_cat":
echo get_the_term_list( $post->ID, 'businesscat', '', ', ', '' );
break;
}
}