Fallback media image for featured image not working in admin column

Question

I want to display a fallback image if a custom post type does not have a featured image set and displayed in a custom admin table column.
However all that is being output is the image url and not the image from the media library.

I have used wp_get_attachment_image_src() to output the image, though I may not be going about it correctly?

// fill column header content
function cpt_columns_content($column_id, $post_id) {
    if ($column_id == 'last_modified') {
        echo get_post_field('post_modified', $post_id);
    } else if ('post_thumbs') {
        the_post_thumbnail('xsm_thumbnail');

    // not sure this is the correct way to go?
    } if (!has_post_thumbnail()) {
        // 156 is the specific media image id
        echo wp_get_attachment_image_src(156, 'archive_thumbnail')[0];
    }
}
add_action('manage_professor_posts_custom_column', 'cpt_columns_content', 10, 2);
add_action('manage_campus_posts_custom_column', 'cpt_columns_content', 10, 2);

0
Krys 5 months 2022-03-08T10:49:11-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse