• Resolved bjihalliday

    (@bjihalliday)


    I am trying to get the title of each post below the thumbnails in my sidebar.

    The code I am currently using is

    <div class="th fl"><?php
      $thumbnails = get_posts('numberposts=4');
      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 '</a>';
        }
      }
    ?>
    
    </div>

    This draws the thumbnails into the sidebar but I cannot seem to be able to get the post titles below these.

    Can someone please help.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Thumbnails in sidebar’ is closed to new replies.