Enter your keyword

Blog

How to Modify Custom Taxonomy Columns

To modify our genre custom taxonomy columns, we must hook into the manage_edit-$taxonomy_columns filter.

Since our taxonomy name is genre, our filter hook becomes – manage_edit-genre_columns

// Add to admin_init function
add_filter("manage_edit-genre_columns", 'theme_columns');  
function theme_columns($theme_columns) {
    $new_columns = array(
        'cb' => '<input type="checkbox" />',
  'gener_images' => 'Image',
        'name' => __('Name'),
  'description' => __('Description'),
        'slug' => __('Slug'),
        'posts' => __('Posts')
        );
    return $new_columns;
}
// Add to admin_init function   
add_filter("manage_genre_custom_column", 'manage_theme_columns', 10, 3);
function manage_theme_columns($out, $column_name, $theme_id) {
    $theme = get_term($theme_id, 'genre');
    switch ($column_name) {
        case 'gener_images': 
            // get header image url
   $genre_image = get_field('genre_image', 'genre_'.$theme->term_id);
      $out .= '<img src="'.$genre_image.'" width="80" />'; 
            break;
 
        default:
            break;
    }
    return $out;    
}

No Comments

Add your review

Your email address will not be published.

* Feilds are Required.