Time for action—using PHP to display the featured image
Using the WordPress editing screen or a text editor, we will open the loop.php
file first. We will then perform the following steps for using PHP to display the featured image:
1. The code we need to insert goes inside the Loop. To find this, we will look for the following code snippet:
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <h1 class="entry-title"><?php the_title(); ?></h1> <section class="entry-content"> <?php the_content(); ?> </section>
On your site the code may look a bit different. You may have
div
tags instead of<article>
and<section>
, which are new elements introduced with HTML5. The specific code may be different. But what will always be there is<?php the_content();?>
.2. On the Carborelli's site, we want to display an image immediately after the heading and before the content, so we will insert our code between the
<h1>
and...