Add Featured Post Thumbnails to WordPress Admin Post Columns

[ad_1]

Have you ever wanted to see the featured post thumbnails associated with your posts, without going through each post individually? Wouldn’t it be nice if you can see all post thumbnails while viewing the list of posts in the WordPress admin? If you want this feature to add in your website then you are in luck because we just have a perfect solution for you. We have a code snippet that does just that by adding an additional column to the list of posts and pages in WordPress admin and displays the featured post thumbnails in it.

WordPress filters mange_posts_columns and manage_posts_custom_column allow us to add custom columns to the list of post & pages in the WordPress admin. These two filters control which columns should be displayed when a user views the list of posts or pages. So we used these functions to add an additional column to the list of posts and pages for displaying featured post thumbnails. You can add this code snippet in your functions.php file of your current theme.

// add featured thumbnail to admin post columns
function wpcs_add_thumbnail_columns( $columns ) {
    $columns = array(
        'cb' => '<input type="checkbox" />',
        'featured_thumb' => 'Thumbnail',
        'title' => 'Title',
        'author' => 'Author',
        'categories' => 'Categories',
        'tags' => 'Tags',
        'comments' => '<span class="vers"><div title="Comments" class="comment-grey-bubble"></div></span>',
        'date' => 'Date'
    );
    return $columns;
}

function wpcs_add_thumbnail_columns_data( $column, $post_id ) {
    switch ( $column ) {
    case 'featured_thumb':
        echo '<a href="' . get_edit_post_link() . '">';
        echo the_post_thumbnail( 'thumbnail' );
        echo '</a>';
        break;
    }
}

if ( function_exists( 'add_theme_support' ) ) {
    add_filter( 'manage_posts_columns' , 'wpcs_add_thumbnail_columns' );
    add_action( 'manage_posts_custom_column' , 'wpcs_add_thumbnail_columns_data', 10, 2 );
    add_filter( 'manage_pages_columns' , 'wpcs_add_thumbnail_columns' );
    add_action( 'manage_pages_custom_column' , 'wpcs_add_thumbnail_columns_data', 10, 2 );
}

This is a very handy code snippet if you use post thumbnail feature very heavily and don’t want to have to edit each post in order to see the thumbnail being used.

[ad_2]

Leave a Reply

Random Post Selection ::

Recent Posts

Unlock Unlimited Downloads