Home Forums Types Community Support [Resolved] Back end customization: adding category column to overview + sorting on taxonomy

[Resolved] Back end customization: adding category column to overview + sorting on taxonomy

This topic contains 6 replies, has 4 voices, and was last updated by  David 11 months, 3 weeks ago. The support staff assigned to this topic is Caridad.

Viewing 7 posts - 1 through 7 (of 7 total)
Author
Posts
#22744

Eva

Hi,

I'm having a question about Types.

I was wondering if it is possible to add a column for your custom taxonomy on a custom post type overview in the back end.

Eg: I have created a custom post type called 'products' and a custom taxonomy 'brands'. I would like to be able to see what 'brand' a product has from the product overview. Similar to how the posts overview page works really. This is especially useful if you have lots of posts, otherwise you always have to check via the quick edit function what category the post is under.

Additionally: is it possible to add a sorting function to the top of the overview page (again, similar to the native posts overview) where you can sort per category?

If anyone can point me in the right direction it would be much appreciated!

#22753

Caridad
Forum moderator

Dear Eva,

This is in our requests list, but it hasnt been scheduled yet. Meanwhile you can use the code suggested in this post:

http://wp-types.com/forums/topic/add-taxonomy-filter-to-admin-posts-menu/#post-12956

Here we are using articles and publication in the same way you want.

Please let me know if there is anything else that I can assist you with.

Regards,
Caridad

#22759

Eva

Thanks for your fast response!

I'm taking you have to substitute the 'publication' in the example with the slug of your custom taxonomy. I tried that with two separate themes but it doesn't seem to work. Am i doing something wrong? > see code below, my custom taxonomy is called 'secties' (slug).

 function add_new_columns($defaults) {
$defaults['secties'] = 'Secties';
return $defaults;
}
function add_column_data( $column_name, $post_id ) {
if( $column_name == 'secties' ) {
$terms = get_the_terms( $post_id, 'secties' );
if ( !empty( $terms ) ) {
$out = array();
foreach ( $terms as $c ) $out[] = $c->name;
echo implode( ', ', $out );
} else {
echo 'Not published';
}
}
}
add_filter( 'manage_article_posts_columns', 'add_new_columns' );
add_action( 'manage_posts_custom_column', 'add_column_data', 10, 2 );	   
#22766

Caridad
Forum moderator

Dear Eva,

You also have to replace article with the slug of your custom type. This is part of the name of the filter.

Please let me know if there is anything else that I can assist you with.

Regards,
Caridad

#22767

Eva

Ah, i missed that one. Thank you very much for your help!

#96948
#154781

rober-

Thanks for the tip on the CodePress Admin Columns. Just tried it out and worked perfectly!!

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

Support Policy

ToolSet staff will help you use Types, Views and CRED correctly, provide any information you need, help troubleshoot problems and advice on best-practices.

Please make sure to issue only one topic per each support ticket.

Need custom programming work for your site? Check out our certified partners.