Assign Thumbnail to a Post
Learn to enable thumbnails and associate an image with a custom post type.
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 ...
<?phpfunction school_features(){add_theme_support('title-tag');register_nav_menu('header-menu', 'Header Menu');register_nav_menu('footer-menu', 'Footer Menu');}add_action('after_setup_theme','school_features');
after_setup_theme hook
...