WordPress – How To Show Thumbnail Gallery In Sidebar

WordPress Aug 19, 2011 1 Comment

There are many ways to show thumbnail gallery in sidebar in WordPress. You can use NextGen plugin or various other plugins.

Following is a very simple and straight forward code to show thumbnail gallery in sidebar.

<?php query_posts(array('orderby' => 'rand', 'cat' => 391, 'showposts' => 12));
if (have_posts()) : while (have_posts()) : the_post(); ?>
          <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
          <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) { the_post_thumbnail(array(71,71), array( "class" => "home_thumb", 'alt' => ''.get_the_title().'') );} ?>
          </a>
          <?php endwhile; ?>
<?php endif; ?>

Above code is pretty straight forward. It shows random thumbnails. you can adjust the width and height as per your requirements and also the number of thmbnails to show.

Wordpress - Sidebar Thumbnail Gallery

Wordpress - Sidebar Thumbnail Gallery

You can see it live on Bollywood blog in right sidebar at the bottom.

Comments

One Response to “ WordPress – How To Show Thumbnail Gallery In Sidebar ”
  1. Diaz Samera

    Nice post.

Leave a Reply to Diaz Samera