Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

So im making an amazon affiliate website. the theme im using (ebuy) enlarges the image when you click on it. I'd rather just have the image take you strait to amazon.

i went poking around in the single-goods.php template and found this:

   <div class="pro-snap">
<?php
if ( has_post_thumbnail() ) { ?>
    <a rel="prettyPhoto" href="<?php get_image_url(); ?> "  title="<?php the_title(); ?>" ><img class="boximg" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&amp;w=200&amp;zc=1" alt=""/></a>
<?php } else { ?>
    <img class="boximg" src="<?php bloginfo('template_directory'); ?>/images/dummy.png" alt="" />
<?php } ?>
</div>

Im new with code but im pretty sure this is telling the site to enlarge the image. how do i go about rewriting this to link them to the product in amazon's website.

thanks :)

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The call to rel="prettyPhoto" is what makes the lightbox popup the image. If you remove that the lightbox will no longer popup.

Now as far as redirecting the user straight to the product page on Amazon, you need to change;

href="<?php get_image_url(); ?>"

to...

href="your_link_to_amazon_product_page_jere"

I don't know where you are storing that link, if at all? Are you storing the link to the product in a custom field? If so, you could do something like;

<div class="pro-snap">
<?php
if ( has_post_thumbnail() ) { ?>
    <a href="<?php echo get_post_meta($post->ID, 'meta_key', true); ?>"  title="<?php the_title(); ?>" ><img class="boximg" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&amp;w=200&amp;zc=1" alt=""/></a>
<?php } else { ?>
    <img class="boximg" src="<?php bloginfo('template_directory'); ?>/images/dummy.png" alt="" />
<?php } ?>
</div>

Where meta_key in the example below is the name of the custom field in which you have stored your product link;

<?php echo get_post_meta($post->ID, 'meta_key', true); ?>
share|improve this answer
    
awesome man! that worked, however it currently takes them off my page and onto amazaon. Do you know how to make the window open in a new tab? –  user34539 Jun 28 '13 at 15:49
    
Add a target="_blank" attribute to your anchor tag. –  userabuser Jun 29 '13 at 1:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.