Image post not shown in frontpage (2 posts)

  1. marinche
    Posted 2 years ago #

    First of all, i want to say Hi to community. I'm really impressed with WP functionality and so many features. Best CMS so far !!
    Ok, now problem...
    I add a picture in my post, after post there is a text. On my frontpage i see only a text. When I click on post, then I see a picture.
    So my question is, how to make a picture visible in frontpage too?
    thank you

    [mod: allow more time to get a reply]

  2. Jay Hoffmann
    Posted 2 years ago #

    You have to make sure that you set a featured image for your posts. Once you do that, you can use the get_post_thumbnail function to call that image to your frontpage. It would end up looking like this, with your post thumbnail and title

      $thumbnails = get_posts('numberposts=5');
      foreach ($thumbnails as $thumbnail) {
        if ( has_post_thumbnail($thumbnail->ID)) {
          echo '<a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">';
          echo get_the_post_thumbnail($thumbnail->ID, 'thumbnail');
          echo get_the_title();
          echo '</a>';

    You'll have to change this to include what you need, so it's probably worth reading up on post thumbnails.


Topic Closed

This topic has been closed to new replies.

About this Topic