Is it possible to add a custom class to the links in admin columns?

I'm trying to replicate the labels below.

Here's an example of what I'm wanting to do.

I'm using WP 4.1 and my CPT is using 'show_admin_column' => true in register_taxonomy and I have two custom taxonomies I'd like to apply this to. I've added a color picker to the add/edit taxonomy pages if that helps with a solution--I found the answer for that here but the usage appears to be on the front-end.

$cat_id = get_cat_ID('Default');
$cat_data = get_option("category_$cat_id");
echo $cat_data['catBG'];

I've searched elsewhere for some kind of solution and I've found a plugin that uses labels in the admin screen but it appears they have custom HTML wrapped around their custom taxonomy links. I'd be happy with that as well if I knew where to start looking.


On edit: I should add that the color will be different for each label. I'd like the ability for the client to choose their own colors for each label (which is why I've added the color picker).

  • 1
    Rather than use the default columns WordPress adds, you can add columns manually and format them how you like. See this answer for an example of adding custom columns.
    – Milo
    Jan 21, 2015 at 18:09

1 Answer 1


Here's what I ending up using thanks to Milo, the Codex and this post from http://simple2kx.com/.

add_action( 'manage_issues_pm_posts_custom_column', 'my_manage_issues_pm_columns', 10, 2 );

function my_manage_issues_pm_columns( $column, $post_id ) {
global $post;
switch( $column ) {
    /* If displaying the 'issues_type' column. */
    case 'issues_type' :
        if ( $terms = get_terms( 'issues_type' ) ) {
            echo '<span>';
                foreach ( $terms as $term ) {
                // The $term is an object, so we don't need to specify the $taxonomy.
                $term_link = get_term_link( $term );
                // If there was an error, continue to the next term.
                if ( is_wp_error( $term_link ) ) {
                // We successfully got a link. Print it out.
                echo '<a class="' . $term->name . '" href="' . esc_url( $term_link ) . '" data-type="label">' . $term->name . '</a>';

            echo '</span>';
        /* Just break out of the switch statement for everything else. */
    default :

Once I get my color picker working (again), I'll add that to my code so I can assign a background color dynamically. For anyone who may be wondering, I'll probably use an inline style to set the background color where I currently have class="' . $term->name . '" in the href.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.