The code snippets inside this download folder enable you to add your featured image on single posts before the 1st H2 Tag or any other HTML tag. This means you can insert your image after any number of paragraphs but before the 1st heading tag like this :
Note : Modify the h2 tags in the PHP code to add your featured image before any type of HTML tags.
Demo Video
Shows the featured image inserted before the first H2 tag on single posts.
Tested using the Twenty Twenty One default theme for WordPress however will work in any WordPress theme.
Installation Steps
There’s 2 steps :
- # Copy & paste one of the the PHP code ( without the opening PHP tag ) snippets to the end of your child themes functions.php file.
- # Upload the content-single.php template to your child themes template-parts > content folder so the template overrides your parent theme file but your code is not lost when your update your parent theme.
Was This Tutorial Helpful?