Enhance your custom theme – Part 2

Step 4: Display your post thumbnails

Once added to your post, you can display the thumbnails by adding the_post_thumbnail() functions.php in the appropriate files.

We will add this code to your index.php and archive.php templates:

<?php the_post_thumbnail(); ?>

And this to our single.php

<?php the_post_thumbnail( 'single-post-thumbnail' ); ?>

Both need to go just above the_content() functions.

Once added, have a look at the source code generated. WordPress, clever as always, provides classes that can be used to style the images.

Comments are closed.