Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 95814

AKApumkin on "custom: expand thumbnails to gallery size using a button"

$
0
0

Hey guys,
So im working through a problem currently and need some help with syntax and logic.

The idea is to display on a template page all the categories relating to that page e.g. page summer and category summer.I have all the categories displaying using a foreach loop and the category post declaration.

// declare variables and arrays parameters
$cat=get_cat_ID($post->summer);
$posts = get_posts ("cat=$cat&posts_per_page=8");
// the loop
if ($posts) {
foreach ($posts as $post):
setup_postdata($post); ?>
       //call each post and display using custom css
<?php endforeach;}?>

So far so good. Inside the loop i call a class (button), that when clicked display's a hidden div outside the loop. This div contains an enlarged version of the thumbnail (think of it as a poor image gallery, with thumbnails type function).

if ($posts) {
foreach ($posts as $post):
setup_postdata($post); ?>
      <div class="container">
          <div class="thumbnail">
             <?php the_post_thumbnail('thumbnail'); ?>
          </div>
          <a class="show"><div class="button"></div></a>
       </div>
<?php endforeach;}?>
//hidden content
<div class="hidden_div">
    <?php the_post_thumbnail('large-thumbnail'); ?>
</div>

My problem is that when enlarged only the last image in the 8 is drawn, now i have tired creating a separate loop for the hidden div, but all 8 images are drawn at the same time. I have also tried to get the post id for each item in the array then set it to a blank variable and call that by setting the id value in the "the_post_thumbnail($postidv,'thumbnail-large')" function.

I think the solution lies in being able to assign a variable to each array button, then call that variable and the image associated from the looped posts and display whichever button is clicked individually.

However after over two weeks working on the problem i have come up against a brick wall, Any help or pointing me in the right direction with this problem would be greatly appreciated.

Cheers,

AKApumkin


Viewing all articles
Browse latest Browse all 95814

Trending Articles