Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Help with on page gallery WordPress


Hello, could someone help me with the best way of creating a simple image gallery and the styling of it.

You can see what I have come up with so far: horsebreedersuk com/stallions/legrande/ (please insert dot before the com in URL to view)

I am using gravity forms to allow customers to upload 5 images, the 1st image they upload would be the main image and the other 4 would be thumbnails. I've got this to work at the moment, but it is through the themes code and I cant get it to look like I want, I have attached an image of how I would like the gallery to look.

Evenly spaced thumbnails and when you click the thumbnails it opens in the main image space.

Not sure if an extra plugin is required for this?

Here is the code I am using at the moment , it is from the arthemia theme.


<?php $status = get_option ( "colabs_postThumb" );
$status2 = get_option ( "colabs_thumbAuto" );

if ( $status != "false" ) { ?>

<?php $width = get_option ( "colabs_thumbWidth_Post" );
$height = get_option ( "colabs_thumbHeight_Post" );
if ( $width == 0 ) { $width = 150; }
if ( $height == 0 ) { $height = 150; }


$status2 = get_option ( "colabs_thumbAuto" );
$values = get_post_meta($post->ID, "image", $single = true);
$id =$post->ID;
$the_content =$wpdb->get_var("SELECT post_content FROM $wpdb->posts WHERE ID = $id");
$pattern = '!<img.*?src="(.*?)"!';
preg_match_all($pattern, $the_content, $matches);
$image_src = $matches['1'][0];

$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );

if ( $status != "false" ) {
if ($image_src=="") {
if ($url!="" || $values!="") {


<?php } ?>
<?php echo do_shortcode('[gallery size="medium" columns="5"]'); ?>

Answers (4)


Charles Klycinski answers:

Im lookin on Your gallery page right now. Ill be happy to help You.

Charles Klycinski comments:

This is solution to fix right sidebar display :

In you page code You need to find
<div class="entry clearfloat">

inside that div You have to setup new div with a left side for example :

<div id="gallery-left">

end of div should be here :

<br style="clear: both;"> </div>

then You have to add to Your css :


This should set right sidebar where You need it. If You will need some extra help with this gallery PM me


Kannan C answers:

I think the thumbss function is only resizing but a thumbnail need a crop. Try use

$thumb_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail');
echo '<img width="70" height="70" src="'.$thumb_image_url[0].'" alt="" />';

instead of thumbss() function


nina magbanua answers:


<strong>first the title</strong>

add style


next add <br class="clear"/> right after <h2 class="title"></h2>

please refer to this link:

<strong>for the stats</strong>

add this style

margin-top: -20px;

<strong>for the infoboxouter</strong>
add this style

right: 384px;

<strong>for the content</strong>

<div class="entry clearfloat">

<div style="margin-bottom: 73px; float:left;"> --> <strong>add this code</strong>

<img src=";w=420&amp;h=350&amp;zc=1&amp;q=100" alt="Legrande" class="left" width="420" height="350">

<style type="text/css">
#gallery-1 {
margin: auto;
#gallery-1 .gallery-item {
float: left;
margin-top: 10px;
text-align: center;
width: 20%;
#gallery-1 img {
border: 2px solid #cfcfcf;
#gallery-1 .gallery-caption {
margin-left: 0;
<!-- see gallery_shortcode() in wp-includes/media.php -->
<div id="gallery-1" class="gallery galleryid-413 gallery-columns-5 gallery-size-medium"><dl class="gallery-item">
<dt class="gallery-icon">
<a href="" title="G4SU7161{26 Legrande"><img width="75" height="66" src="" class="attachment-medium" alt="G4SU7161{26 Legrande" title="G4SU7161{26 Legrande"></a>
</dt></dl><dl class="gallery-item">
<dt class="gallery-icon">
<a href="" title="G4SA5513{ 26 Legrande"><img width="75" height="57" src="" class="attachment-medium" alt="G4SA5513{ 26 Legrande" title="G4SA5513{ 26 Legrande"></a>
</dt></dl><dl class="gallery-item">
<dt class="gallery-icon">
<a href="" title="300 dpi DSF_4797[1]"><img width="52" height="75" src="" class="attachment-medium" alt="300 dpi DSF_4797[1]" title="300 dpi DSF_4797[1]"></a>
</dt></dl><dl class="gallery-item">
<dt class="gallery-icon">
<a href="" title="img_6979_med"><img width="75" height="55" src="" class="attachment-medium" alt="img_6979_med" title="img_6979_med"></a>
</dt></dl><dl class="gallery-item">
<dt class="gallery-icon">
<a href="" title="forest16"><img width="67" height="75" src="" class="attachment-medium" alt="forest16" title="forest16"></a>
</dt></dl><br style="clear: both">
<br style="clear: both;">
<div class="infoboxouter" style="position:absolute; right: 384px;">
<div class="infoboxtitle">Stallion</div>
<div class="infobox">
<p><strong>Height:</strong> <a href="" target="_self">16.2</a></p>

<p><strong>Colour:</strong> <a href="" target="_self">Buckskin</a></p>

<p><strong>Discipline:</strong> <a href=" Jumping" target="_self">Show Jumping</a></p>

<p><strong>Breed:</strong> <a href="" target="_self">Oldenburg</a></p>

<p><strong>Year of Birth:</strong> <a href="" target="_self">2003</a></p>

<p><strong>Studbook:</strong> Oldenburg</p>

<p><strong>License #:</strong> Anglo European Studbook</p>

<p><strong>EVA Negative:</strong> Yes</p>

<p><strong>Stud Fee:</strong> £600 (not including collection and postage costs)</p>
<div class="infoboxclean">
<div class="social4i" style="height:69px;float: right;"><div class="social4in" style="height:69px;float: right;"><div class="socialicons s4twitter" style="float:left;margin-right: 10px;background:url(&quot;;) no-repeat;"><iframe src=";count=vertical&amp;;id=twitter-widget-0&amp;lang=en&amp;;text=Legrande&amp;" allowtransparency="true" frameborder="0" scrolling="no" class="twitter-share-button twitter-count-vertical" style="width: 55px; height: 62px; " title="Twitter For Websites: Tweet Button"></iframe></div><div class="socialicons s4fblike" style="float:left;margin-right: 10px;"><div id="fb-root"></div><fb:like href="" send="false" layout="box_count" width="55" height="62" show_faces="false" font="" class=" fb_edge_widget_with_comment fb_iframe_widget"><span><iframe id="f330928e5c" name="f141b40f4" scrolling="no" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; overflow-x: hidden; overflow-y: hidden; height: 65px; width: 55px; " title="Like this content on Facebook." class="fb_ltr" src=";extended_social_context=false&amp;;layout=box_count&amp;locale=en_US&amp;node_type=link&amp;sdk=joey&amp;send=false&amp;show_faces=false&amp;width=55"></iframe></span></fb:like></div><div class="socialicons s4plusone" style="float:left;margin-right: 10px;"><div id="___plusone_0" style="height: 60px; width: 50px; display: inline-block; text-indent: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; float: none; line-height: normal; font-size: 1px; vertical-align: baseline; background-position: initial initial; background-repeat: initial initial; "><iframe allowtransparency="true" frameborder="0" hspace="0" id="I1_1323110872026" marginheight="0" marginwidth="0" name="I1_1323110872026" scrolling="no" src=";size=tall&amp;count=true&amp;annotation=&amp;hl=en-US&amp;jsh=m%3B%2F_%2Fapps-static%2F_%2Fjs%2Fwidget%2F__features__%2Frt%3Dj%2Fver%3Dixet_KG_yRY.fil.%2Fsv%3D1%2Fam%3D!8NuGo4ypxRCIwtBaLA%2Fd%3D1%2F#id=I1_1323110872026&amp;;rpctoken=175293425&amp;_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe" style="width: 50px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; height: 60px; position: static; left: 0px; top: 0px; visibility: visible; " tabindex="-1" vspace="0" width="100%" title="+1"></iframe></div></div></div><div style="clear:both"></div></div></div>
<a href="" title="Print This Page" rel="nofollow"><img class="WP-PrintIcon" src="" alt="Print This Page" title="Print This Page" style="border: 0px;"></a>&nbsp;<a href="" title="Print This Page" rel="nofollow">Print This Page</a>

</div> -- <strong>close the div</strong>

<div class="clear"></div> --<strong> add this one</strong>

<p><strong>Video:</strong> <a href=";feature=player_embedded" target="_blank">;feature=player_embedded</a></p>
<br class="clear">

for page reference:


Francisco Javier Carazo Gil answers:

Hi Ross,

Why are you using a <p> tag in your div with "entry clearfloat" class. I suggest to delete the <p> tag and make the image float left with a div as Charles says.

Moreover, I would use a gallery plugin like this one:

Hope it helps!