Underscores 4.3 Add featured image

@kezzbracey I am having trouble figuring out how to enable the featured image at 4.3 (Add Featured Image Support).My underscores does not have the content.php.
There is a similar qoestion in the forum byt I don’t understand the information on the link applied as an answer there.

Please help. I.m stuck!

Hi @Lillbre,

Let me try to answer your question - the “content.php” file should be available in “template-parts” directory.

Once confirmed, please locate and open “functions.php” file available in main theme directory. If file hasn’t been modified, you should have following line under line 43:

add_theme_support( 'post-thumbnails' );

If it’s not there, check the entire file as this line is essential for featured image to show up later. If there’s no such line at all, add it at the end of your “functions.php” file.

Now save the file and head over to “content.php”. Again, if file hasn’t been modified, look for line number 15. You should see following code there:

if ( is_singular() ) : 
    the_title( '<h1 class="entry-title">', '</h1>' );
else :
    the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
endif;

Now add following code just above the previous one:

if ( has_post_thumbnail() ) :
    the_post_thumbnail( 'full' );
endif;

If you’ve followed all the steps correctly, featured image will be visible from now on just above post title. You will most likely have to adjust its appearance in “style.css” file later on.

Thanks,
Luca

Thank you for your effort @lucalogos. The problem is that there is no content.php in ”template-parts” directory. I tried to google it and it seems as if there have been changes made to underscores. Great course and now I feel frustrated to get stuck so close to end.
Thanks again
Lllian

Skickades från E-post för Windows 10

Oh, I see. You may need to get the most recent version of underscores framework then, I’m not sure what was its’ structure back then.

You can also do a global search for certain characters in all the files, that will help you find the part with post title. Overall code structure should be similar, just look for this part:

<h1 class="entry-title">

Thanks,
Luca

1 Like

Thank you very much for your help @lucalogos

Skickades från E-post för Windows 10

Hi @Lillbre, my apologies for missing your post, I’ve been away with some time off this past month.

I’m going to see about putting together an update for this course given the file structure of Underscores was modified since its release.

I’d try to point you in the right direction now but I’ve gone through some major PC and operating system reinstalls since I last looked at this course’s content and as such I don’t have a WP dev environment or the source files handy right now. It will just take me a little time to get all that setup again, which I hope to do as part of creating an update.

I’ll post back to let you know.