Home / admin / Create custom terms admin column
  • How to Create custom terms admin column

    create-custom-terms-admin-column

    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.

    ( click code to copy )

    wordpress snippet : PHP

    <>
        // 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', '', ', ' );
           }
    }
    

    ( WordPress codex functions, hooks, in this snippet. )

    manage_posts_columns, manage_pages_columns, the_terms, add_filter, add_action, __, _n, wp,