Customowa kolumna w backendzie
//pobieranie featured image
function ST4_get_featured_image($post_ID) {
$post_thumbnail_id = get_post_thumbnail_id($post_ID);
if ($post_thumbnail_id) {
$post_thumbnail_img = wp_get_attachment_image_src($post_thumbnail_id, 'featured_preview');
return $post_thumbnail_img[0];
}
}
// Add to admin_init function
add_filter('manage_edit-produkty_columns', 'add_new_produkty_columns');
function add_new_produkty_columns($gallery_columns) {
$new_gc =$gallery_columns;
unset($new_gc["date"]);
$new_gc['kod']=__('ID');
$new_gc['images']=__('Zdjęcie');
return $new_gc;
}
// Add to admin_init function
add_action('manage_produkty_posts_custom_column', 'manage_produkty_columns', 10, 2);
function manage_produkty_columns($column_name, $id) {
global $wpdb;
switch ($column_name) {
case 'kod':
echo get_field('kod',$id);
break;
case 'images':
// Get number of images in gallery
$post_featured_image = ST4_get_featured_image($id);
if ($post_featured_image) {
// HAS A FEATURED IMAGE
echo '<img src="' . $post_featured_image . '" />';
}
break;
default:
break;
} // end switch
}