$25
Add Category Column & Filter a Custom Post Type
I have set up a custom post type in WP 3.1 following code which works:
Question 1
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.
Question 2
I require coding to create a drop down filter in my admin view that lists the categories so I can filter by category.
Requirements
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.
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');Question 1
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.
Question 2
I require coding to create a drop down filter in my admin view that lists the categories so I can filter by category.
Requirements
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.
parksey18 | 03/04/11 at 3:38am
| Edit
Previous versions of this question:
03/04/11 at 5:46am
(2) Possible Answers Submitted...
-
Last edited:
03/04/11
4:25pmOleg Butuzov says:if you can encrease prize to 25 i can help you =)
- 03/04/11 5:47am
parksey18 says:$25 it is.
- 03/04/11 5:47am
Oleg Butuzov says:work start... timer on.
- 03/04/11 9:13am
Oleg Butuzov says:sebastien... its already done and sent...
- 03/04/11 9:13am
Oleg Butuzov says:Few hours ago...
- 03/04/11 4:27pm
parksey18 says:Cheers Oleg, thanks for the prompt and thorough code.
- 03/04/11 5:47am
-

Last edited:
03/04/11
7:42amSébastien | French WordpressDesigner says: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;
}
}
This question has expired.
Current status of this question: Completed





