X

Create custom terms admin column

footer area widgets

This is a simple little snippet that will add your custom terms in an admin column. I added both the filter and action for both posts and pages, feel free to use both or choose one. Add this snippet to the functions.php of your wordpress theme but be sure to change TERM_NAME on this line echo the_terms( $id, 'TERM_NAME', '', ', ' ) in the snippet to the name of your term. You will then see your terms displayed exactly the same way as you see categories displayed within the admin section.


    // for pages
    add_filter('manage_pages_columns', 'term_columns_id', 5);
    add_action('manage_pages_custom_column', 'term_custom_id_columns', 5, 2);

    // for posts
    add_filter('manage_posts_columns', 'term_columns_id', 5);
    add_action('manage_posts_custom_column', 'term_custom_id_columns', 5, 2);


function term_columns_id($defaults){
    $defaults['wps_post_type'] = __('Term');
    return $defaults;
}
function term_custom_id_columns($column_name, $id){
	if($column_name === 'wps_post_type'){
	echo the_terms( $id, 'TERM_NAME', '', ', ' );
       }
}

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!