Watch every course in the library with a membership.
Each course includes high-quality videos taught by expert instructors.


Style the featured image Build Wordpress Themes

Once you've set your featured image in your template, you'll want to apply styles so that it looks e… Show More

WordPress: Building Themes from Scratch Using Underscores (2014)

with Morten Rand-Hendriksen

Video: Style the featured image Build Wordpress Themes

Once you've set your featured image in your template, you'll want to apply styles so that it looks exactly the way you want it to when the page is displayed. You can adjust things like the page alignment and the image resolution. This video tutorial will show you how to style the featured image of a blog post as you build out your WordPress themes.
Expand all | Collapse all
  1. 10m 55s
    1. Welcome
      1m 4s
    2. What to know before you start this course
      2m 40s
    3. How this course and the lesson files work
      3m 12s
    4. Introducing Simone: A preview of the final project
      3m 59s
  2. 21m 28s
    1. Installing and running WordPress on your computer
      3m 53s
    2. Getting and installing Underscores
      4m 11s
    3. Installing WordPress Theme Unit Test data
      4m 18s
    4. Installing the Developer plugin
      2m 58s
    5. Installing and setting up NetBeans or another IDE
      6m 8s
  3. 16m 15s
    1. Designing for mobile, content, and style
      4m 52s
    2. How do WordPress themes work?
      4m 48s
    3. Understanding the WordPress template hierarchy
      2m 19s
    4. Underscores: An overview
      4m 16s
  4. 37m 5s
    1. Setting up style.css
      4m 47s
    2. Configuring baseline settings and functions
      6m 6s
    3. Enabling custom fonts and font icons
      5m 44s
    4. Applying global styles
      5m 11s
    5. Styling basic layout components
      6m 19s
    6. Making the site layout responsive
      8m 58s
  5. 23m 18s
    1. Styling the default header
      6m 25s
    2. Hiding the site title and tagline
      5m 32s
    3. Adding an optional header image function
      5m 23s
    4. Placing the header image behind the site title
      5m 58s
  6. 40m 55s
    1. Setting up menus
      3m 12s
    2. Styling the menu
      7m 42s
    3. Using Superfish for accessible menus
      8m 0s
    4. Making the menu responsive
      7m 3s
    5. Creating a custom social media menu
      5m 51s
    6. Styling the menu with icons from Font Awesome
      9m 7s
  7. 18m 9s
    1. Adding the search form
      6m 27s
    2. Adding the search icon
      6m 55s
    3. Adding show/hide functionality to the search form with jQuery
      4m 47s
  8. 33m 20s
    1. Adding a widgetized area to the footer
      7m 10s
    2. Using the Monster widget plugin to test all widgets
      2m 11s
    3. Styling the footer
      3m 6s
    4. General widget styling
      5m 33s
    5. Adding custom styles to specific widgets
      7m 34s
    6. Using Masonry to make footer widgets responsive
      7m 46s
  9. 54m 49s
    1. Changing the Single Post Template content structure
      5m 54s
    2. Changing the output of meta elements
      7m 2s
    3. Styling the Single Post Template
      7m 57s
    4. Making post meta responsive
      6m 21s
    5. Styling blockquotes
      5m 39s
    6. Creating pull quotes and pull images
      5m 1s
    7. Working with image captions
      4m 27s
    8. Working with image galleries
      4m 57s
    9. Single-post navigation
      7m 31s
  10. 30m 23s
    1. Working with the comments template
      8m 42s
    2. Using Gravatars in comments
      2m 42s
    3. Styling comments
      7m 26s
    4. Highlighting post author comments
      3m 36s
    5. Styling the comment form and messages
      7m 57s
  11. 18m 43s
    1. How do featured images (post thumbnails) work?
      2m 57s
    2. Defining featured image sizes
      3m 30s
    3. Generating new featured images with a plugin
      1m 46s
    4. Adding featured images to a template
      5m 7s
    5. Styling the featured image
      5m 23s
  12. 1h 2m
    1. The index template hierarchy
      2m 21s
    2. Customizing and styling index templates
      10m 10s
    3. Displaying excerpts or full content on index pages
      3m 6s
    4. Adding a custom Read More link
      3m 48s
    5. Adding featured images
      4m 0s
    6. Creating custom pagination navigation
      6m 4s
    7. Highlighting Sticky Posts
      2m 55s
    8. Creating custom post format templates
      5m 30s
    9. Highlighting the most recent post in the index template
      7m 22s
    10. Embracing modular design
      2m 29s
    11. Working with archive.php
      5m 54s
    12. Customizing the search results and the 404 template
      8m 28s
  13. 9m 7s
    1. Styling pages
      3m 4s
    2. Creating custom page templates
      6m 3s
  14. 4m 30s
    1. Adding editor styles to match front-end styles
      4m 30s
  15. 2m 20s
    1. Further learning
      2m 20s

please wait ...
Styling the featured image
Video duration: 5m 23s 6h 23m Advanced


Once you've set your featured image in your template, you'll want to apply styles so that it looks exactly the way you want it to when the page is displayed. You can adjust things like the page alignment and the image resolution. This video tutorial will show you how to style the featured image of a blog post as you build out your WordPress themes.

WordPress underscores

Styling the featured image

Now that we have featured images in our single post templates, we're going to start applying styles to them to make them look exactly how they want. But before we do so, let's just see how the images behave right now in responsive environments. Because, if you take the post that you have with the very large featured image, and you resize it to a smaller browser width. You'll see that the featured image automatically inherits the responsive styling of images from the Underscores theme. So here you see, as I scale down to a much smaller window, the image proportionally resizes to fit that smaller window.

So, the only thing we need to worry about is images that are smaller than they're supposed to be. And also what happens to images that are displayed on very large screens. Because, if you'll remember, the two featured image posts that came with the theme unit test data, have smaller featured images. And you can see that they align all the way to the left. Now that might look acceptable on the screen I have right now, but if you go to a very large screen, it'll look weird because the image will be all the way over the on the left, and the content will be in the middle. So here I've made some design fall backs.

The first thing I want to do is place the image in the middle directly above the posts. And then I also want to add a rasterized background behind the Featured Image section, so that the Featured Image section is a separate element from the rest of the post. So we'll start by adding that rasterized background, and then using the class we applied in the previous movie to center align the featured image. First, I need the rasterized background itself, and if you go to the exercise files for this course, you'll find a folder called Images.

And, within that folder, you have a single file called pattern.svg. So I'm going to take the Images folder and copy it into my theme. So, here on the right, I have WordPress installed on my computer. I'm going to go to, wp-content > themes > my-simone, and I'm simply going to grab images and just copy it into my themes folder. And that way I can target pattern.svg using CSS. So, if we quickly look back at the code we added in the previous movie, we wrapped our featured image in a div with a class, single_post_thumbnail, that clears, meaning it spans the full width of the screen.

So now I can go to style.css and find where I want to insert the featured image code. And if you look at the table of contents, you'll see here we have 12.0 Media. So I'm going to find 12.0. Here's the media and I'm going to scroll to the bottom of the Media section. And then I'm going to add the featured images at the bottom here because they're optional. So I'll just put in Featured Images, and here I want to add in the styling that both adds that background, and also aligns the image in the middle.

In my code snippets I have those two rules, they're right here, so I'll copy them out, and paste them in. And here you see the first rule targets the container. So single-post-thumbnail sets the background to the same grey we set previously in the course. And then sets a background url, so that's the image, to that pattern.svg, and repeats it. The second one just displays the image itself as a block element, and then aligns it to the middle by setting left and right margins to auto. So I'll save that, and go and reload one of the posts that have the smaller images.

And now you see the image aligns in the center of the current container, and we have this rasterized background effect behind the image. Same goes for the other image here. And if you're on a much larger screen you'll see, as you scale the screen up, the image will always align to the center of the main container, and you'll have that nice rasterized background behind everything. And this works great, but, if you want to take this one step further, and you want to really follow my design closely you can add some additional code. So I've added some additional code to make the featured image even more responsive in the code snippets.

So here you have optional code for content single. I'll copy that out, and go to content single and I'll just replace the top element here. And what this code does is, it adds an additional div within the single post thumbnail div called, image-shifter. And this image-shifter will be used to shift the image so that it aligns to the right-hand side on smaller screens. And then aligns to the center on larger screens, and that's done using a bit of custom CSS with mediaqueries.

So here you see you have some mediaqueries, that we can copy out, and paste in below our featured image call. And these media queries target different screen sizes. So here you see with target screens that are from 1440 pixels wide to 1820 pixels wide. And what you'll see here is on much larger screens, the image will now shift to align with the alignment of the content. because, you'll remember, previously I explained that on larger screens, the content will first align to the right-hand side and then start aligning to the center, and now the featured images will do the same.

They'll start by aligning to the right-hand side, and then align to the center. So if you have a larger screen, apply that extra set of code, and experiment with resizing your window to see exactly how this extra responsive code kicks in.

There are currently no FAQs about WordPress: Building Themes from Scratch Using Underscores (2014).






Don't show this message again
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed WordPress: Building Themes from Scratch Using Underscores (2014).

Return to your organization's learning portal to continue training, or close this page.


Upgrade to View Courses Offline


With our new Desktop App, Annual Premium Members can download courses for Internet-free viewing.

Upgrade Now

After upgrading, download Desktop App Here.

Course retiring soon

WordPress: Building Themes from Scratch Using Underscores (2014) will be retired from the library on February 15, 2016. Training videos and exercise files will no longer be available, but the course will still appear in your course history and certificates of completion. For updated training, check out WordPress: Building Themes from Scratch Using Underscores in the Online Training Library.

Become a Member and Create Custom Playlists

Join today and get unlimited access to the entire library of online learning video courses—and create as many playlists as you like.

Get started

Already a member?

Log in

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

You started this assessment previously and didn’t complete it.

You can pick up where you left off, or start over.

Resume Start over

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.