Time for action – adding featured images to the site

Adding featured images is done in the admin screen for each page or post.

  1. Open the editing screen for a post or page, as shown in the following screenshot:
    Time for action – adding featured images to the site
  2. On the right-hand side, below the Categories box, is the box for uploading featured images.

    Tip

    Can't see a featured images box?

    If you can't see the box for uploading featured images, it's because you don't have the functionality in your theme. Your theme's functions.php file must have the code we added previously in order for this box to show up.

  3. Click on Set featured image to open the featured images pop up:
    Time for action – adding featured images to the site
  4. Upload your image as you would for any other image.
  5. Once you've uploaded the image, don't click on the Insert into Post button, instead, click on Use as featured image.
  6. Click on the Save all changes button to return to the post editing screen.
  7. To close the featured images pop up, click on the small X sign in the upper-right corner.
  8. Click on the Update button to save the changes to your post or page.
  9. You will now see your featured image displayed in the editing screen:
    Time for action – adding featured images to the site
  10. Repeat steps 3 to step 8 for some more posts and pages.

What just happened?

We added featured images to some of the pages and posts in our site. Now let's see how they look on the site.

First, in a single post:

What just happened?

Next, on our home page which lists all of our posts:

What just happened?

The image on the single post looks great and fits well into our layout. But the images on the home page are a bit large. Luckily, WordPress makes it easy for us to change that. We can set up a new template file just for single posts, and then edit our index.php file so it displays smaller featured images. This means when any archive listings are using index.php, they will display the smaller image.

Tip

There is an alternative way to do this. We could set up an archive.php file for displaying all our archive listings, and leave index.php as it is. Or we could use both single.php and archive.php, for even greater control. As you get more advanced with your WordPress theme development, you'll find that there's often more than one way to solve a problem, and that the best one may be simply the one that works best for you.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.229.113