Envira Gallery Documentation

Documentation, Reference Materials and Tutorials for Envira Gallery

Display Adsense Ads in Lightbox

Would you like to display Adsense Ads inside your gallery images’ lightbox? Envira Gallery makes that easy to do after a little customization. Let’s take a look at how to do this!


First, add the following code to your functions.php file. Be sure to replace my-ad-script-here with the script generated for your Adsense Ad.

add_filter( 'envirabox_inner_below', 'envira_add_ads', 11, 2 );
function envira_add_ads( $template, $data ){

 template .='<div align="center">my-ad-script-here</div>';

return $template;

}

The above code will display your Adsense Ad above the image in Envira Gallery’s lightbox.
Adsense in Lightbox

That’s it! You’ve just added Adsense functionality to Envira Gallery. For more customization to Envira Gallery’s lightbox, check out how to style image title and caption hover effects.