Forums

Passing variables -- a tricky little image carousel coding puzzle (1 post)

  1. benfranklin
    Member
    Posted 1 year ago #

    I am hoping this simplified code explains what I need help with ... I have a homepage carousel that loads random images from a loop of 5 posts ... I choose which posts via a tag.

    For these 5 images, there are also 5 thumbnail images that exist outside the loops in the HTML structure but need to correspond to the main thumbs above.

    Sample code -- simplified:
    <? query_posts('tag=carousel&orderby=rand&showposts=3'); ?>
    <? if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <img src="<? echo "$thumb1" />" />
    <? endwhile; else: ?>
    <? endif; ?>

    <div>
    <img src="<? echo "$thumb1" />" />
    <img src="<? echo "$thumb2" />" />
    <img src="<? echo "$thumb3" />" />
    </div>
    `
    So as you can see ... I need a way for that first variable, thumb1 to become a different identifiable variable that is establish so I can just plug it in for the thumbs below.

    Anyone done something like this before?

Topic Closed

This topic has been closed to new replies.

About this Topic