Some customers are asking me on how to link gallery images to a sponsor URL. Actually this is very easy, but requires a slight modification of your WordPress theme.
Let's consider that CyberSEO plugin pulls some sponsor FHG feed or parses a CSV dump with links to FHG's. The plugin generates WP posts with galleries and puts your affiliate link into the "
paysite" custom field.
So if you want to link every full-sized gallery image (not a small thumbnail) to your affiliate link, you should open your
attachment.php template and find there a line like this:
Code:
<a href="<?php echo wp_get_attachment_url(); ?>"><img src="<?php echo wp_get_attachment_url(); ?>" alt="<?php the_title_attribute(); ?>" /></a>
now just modify it as follows and save the template:
Code:
<a href="<?php echo get_post_meta(wp_get_post_parent_id(get_the_ID()), "paysite", true); ?>" target="_blank" rel="nofollow"><img src="<?php echo wp_get_attachment_url(); ?>" alt="<?php the_title_attribute(); ?>" /></a>
Vualà: now all your gallery images are linked to your sponsor's paysite with your own affiliate code of course - go get a shovel to grab your bucks