Forums

Problem linking custom field images to other custom field images (3 posts)

  1. boxadesign.co.uk
    Member
    Posted 1 month ago #

    Hello all,

    Okay, I have actually got this working, but not correctly.

    I am using a featured content gallery plugin to display work in my portfolio - this obviously show content on a post basis.

    Each post uses a custom field 'Thumbnail' to show an image. I have that custom field linking to another image custom field (within the same post) that when clicked displays in a fancy box.

    This works but when you click the image it shows the fancybox okay but grabs the custom field image from teh most recent post. Its falling out of the loop somewhere.

    As I'm no php expert I think i've hashed some code together but obviously done something wrong. Here is my code...

    <div id="slider">
    <div id="mygallery" class="stepcarousel">
    <div class="belt">
    	<?php $temp_query = $wp_query; ?>
            <?php query_posts('cat=' . get_option('slider-id') . '&showposts=' . get_option('slider-items')); ?>
            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="panel">
    <div class="slide-details">
    <h2><?php the_title(); ?></h2>
    <?php the_content(); ?>
    </div>
    <div class="main_view">
    <a class="fancybox" href="#customimage"><img src="<?php bloginfo('template_url'); ?>/images/<?php echo get_post_meta($post->ID, 'Thumbnail', true); ?>"></a>
    </div>
    <div id="customimage">
    <img src="<?php bloginfo('template_url'); ?>/images/<?php echo get_post_meta($post->ID, 'popup', true); ?>">
    </div>
    </div>
            <?php endwhile; else: ?>
            <?php endif; ?>
    </div>
    </div>
    </div>

    The first link in the main_view div links to #customimage - this contains the custom field image that opens in fancybox. The #customimage div is set to display:none. (Just in case you wondered how it worked).

    Again, it actually works but shows the image of the custom field value of 'popup' from the most recent post and not the current post. Do I have to do something with 'foreach'?

    Any help would be great.

    Thanks, Matt

  2. boxadesign.co.uk
    Member
    Posted 1 month ago #

    This has gotta be a two minute post for someone who knows what they're doing?!

  3. boxadesign.co.uk
    Member
    Posted 1 month ago #

    Anyone got any ideas on this? I'll unfortunately have to ditch it for a while as I gotta go live this week.
    Thanks, Matt

Reply

You must log in to post.

About this Topic