Assign Thumbnail to a Post

The easiest way to add an image to a post is to use the image block when creating a post. The only downside is that the image will be added to the content. If we keep the image and content separate but form an association between them, that we can display the image at different locations on our website.

Enable thumbnails for posts

We will associate a featured image with our post. By default, themes do not support this option. To enable this option we need code that gets executed on the after_setup_theme hook.

Open the functions.php file. It has a function school_features() that adds support for extra features for our theme. We added dynamic menus and modified the Browser tab title through this function. The code is reproduced below:

Get hands-on with 1200+ tech skills courses.