• Hi,

    I am exploring on codex and found this code

    <?php
      $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 '</a>';
        }
      }
    ?>

    Now I have installed it on my homepage and it works as I want but I have one problem which is I want the corresponding featured image have same dimension sizes.

    Please help me with the codes,

    thanks in advance
    Nimitz
    http://www.nbatioco.com

Viewing 1 replies (of 1 total)
  • Thread Starter nbatioco

    (@nbatioco)

    Okey I made it work.. Here’s how,

    <?php
      $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, array(200,250));
          echo '</a>';
        }
      }
    ?>

    But still, it would give me the exact sizes that I desire my theme supports timthumb but I dont know how to use it.

    On the single post —

    <span class="image" style="background-image: url(<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext, true, true); ?>);">
    			   <img src="<?php bloginfo('template_directory'); ?>/images/thumb-overlay.png" alt="" />
    			</span>

Viewing 1 replies (of 1 total)

The topic ‘Featured Image’ is closed to new replies.