View Single Post
Old 05-20-2017, 02:29 AM  
just a punk
So fuckin' bored
 
just a punk's Avatar
 
Industry Role:
Join Date: Jun 2003
Posts: 32,332
Linking gallery images to a sponsor

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
__________________
Obey the Cowgod
just a punk is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote