Skip to content

Instantly share code, notes, and snippets.

@wpsoul
Created February 27, 2016 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpsoul/030627958ec48302d046 to your computer and use it in GitHub Desktop.
Save wpsoul/030627958ec48302d046 to your computer and use it in GitHub Desktop.
Use for adding link from offer to all post images
<script>
jQuery(document).ready(function($) {
if ($('.single-post .btn_offer_block').length > 0) {
var linkoffer = $('.single-post .btn_offer_block').first().attr('href');
$('img[class*="wp-image-"]').each(function(){
if($(this).parents('a').length == 1){
return;
}
else{
$(this).wrap('<a href="' + linkoffer + '" target="_blank" rel="nofollow"></a>');
}
})
}
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment