WordPress Snippets

Code Snippet

By default, WordPress does not show the featured image of a page in the backend list, but it can be helpful to see if one is missing or the wrong image has been placed.

PHP

Place the following code anywhere in your child theme’s functions.php document. The following will show each page’s featured image in the backend pages list. If a featured image is not set, the area will remain blank.

// add featured image to the backend "pages" list
add_filter( 'manage_pages_columns', function ( $columns ) {
    $columns['page_thumbnail'] = __( 'Featured Image' );
    return $columns;
} );
	
add_action( 'manage_pages_custom_column', function ( $column, $post_id ) {
    if ( 'page_thumbnail' === $column ) {
        echo get_the_post_thumbnail( $post_id, array( 60, 60 ) );
    }
}, 10, 2 );

Note

This has NO AFFECT on the front end of your site. This only applies to the backend list of pages.

Note

All modifications to a theme or plugin should be made by creating a child theme and placing the changes there. Changes made to the parent theme will be overwritten the next time it updates.


WordPress Notes:

  • All modifications to a theme or plugin should be made by creating a child theme and placing the changes there; changes made to the parent theme will be overwritten the next time it updates

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.