WordPress.org

Forums

[resolved] post thumbnails not showing (8 posts)

  1. djvirusz
    Member
    Posted 4 years ago #

    hi there,

    in the past few days i struggled with this but no success. already checked with the codex and the many tutorials found online :(

    my website is this: http://www.cumesaj.ro
    everything works smooth besides the post thumbnails which are not showing.

    my functions.php looks like this...

    <?php
    
    if ( function_exists( 'add_theme_support' ) )
    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 125, 125 );

    and my header.php tries to show the thumbnails with this code:

    <img src="<?php the_post_thumbnail(); ?>" alt="thumbnail" class="thumbnail" />

    in my panel, under posts, the thumbnails function looks activated and i added a thumbnail for one of the posts (the one that echoes this instead of showing the thumbnail: " alt="thumbnail" class="thumbnail" />)

    any help will be greatly appreciated!

    thanks

  2. You don't need the <img src="" alt=""/>

    just put <?php the_post_thumbnail(); ?>

    and word press will display the image and add the alt, size, title, and caption if defined.

  3. djvirusz
    Member
    Posted 4 years ago #

    thanks! my index.php now looks like this:

    <img src="<?php the_post_thumbnail(); ?>" />

    actually i tried this before but no luck...

    anyone else? :)

  4. Change this: <img src="<?php the_post_thumbnail(); ?>" />

    to this: <?php the_post_thumbnail(); ?>

  5. djvirusz
    Member
    Posted 4 years ago #

    thanks so much, we did some progress. now it's showing the thumbnail picture but it ignores the css and alignments.

    i guess the function should be placed somehow under <image> in order for the thumbnail to look nice and for the post summary to show up the way it was designed.

  6. WordPress assigns the following classes to the_post_thumbnail:

    class="attachment-post-thumbnail wp-post-image"

    Or you can assign a div class to the image:
    <div class="thumbnail"><?php the_post_thumbnail(); ?></div>

    To target the default WP classes in your css:

    img.attachment-post-thumbnail {css stuff;}

  7. djvirusz
    Member
    Posted 4 years ago #

    this worked as a charm

    <div class="thumbnail"><?php the_post_thumbnail(); ?></div>

    your're a genius man! forever respect to you!

  8. bobjones
    Member
    Posted 4 years ago #

    I'm running WP 3.1 and also can not get post thumbnails to display at all by editing my custom theme. I've read all the tutorials and the codex and inserted all the recommended code in functions.php and my theme. But nothing shows up.

    Further, I've seen no explanation of exactly how I'm supposed to know post thumbnails are activated. Will the script automatically grab the first image from the post and place it as a thumbnail on my front page or category pages or archive pages or single pages, depending on where I've placed the script?

    Will there be an "insert thumbnail" option in my admin page? That isn't explained anywhere.

    I've been able to get post thumbnails to work one way -- by using the thumbnail-for-excerpts plugin. But I want to activate post thumbnails without using a plugin.

Topic Closed

This topic has been closed to new replies.

About this Topic