Showing posts with label how to add custom column in wordpress categoty or texonomy admin panel in wordpress. Show all posts
Showing posts with label how to add custom column in wordpress categoty or texonomy admin panel in wordpress. Show all posts

Sunday, 13 March 2016

how to add custom column in wordpress categoty or texonomy admin panel in wordpress

how to add custom column in wordpress categoty or texonomy admin panel in wordpress


// product-category is my custom category change your texonomy
add_filter("manage_edit-product-category_columns", 'theme_columns');

function theme_columns($theme_columns) {
    $new_columns = array(
        'cb' => '<input type="checkbox" />',
        'name' => __('Name'),
        'category' => 'Category Banner',
      'description' => __('Description'),
        'slug' => __('Slug'),
        'posts' => __('Posts')
        );
    return $new_columns;
}


add_filter("manage_product-category_custom_column", 'manage_theme_columns', 10, 3);

function manage_theme_columns($out, $column_name, $theme_id) {
    $theme = get_term($theme_id, 'product-category');


global $post;

    switch ($column_name) {
        case 'category':
            // get header image url

           $variable = get_field( 'category_image', 'product-category_'.$theme_id );//here advace customfield value you can use your custom field;
           if(!empty($variable)){
            $out .= "<img src=".$variable." height='83px' width='150px'/>";
   }
            break;

        default:
            break;
    }
    return $out;   
}