Amazon Affiliate Ad

I am trying to add the code for an Amazon mobile pop up add, and the instructions are to add the code in the Footer.php file before the body tag. My Footer.php file does not have a reference to body. Where do I insert this code? Here is what currently displays in my Footer.php

<?php // ============================================================================= // FOOTER.PHP // ----------------------------------------------------------------------------- // The site footer. // ============================================================================= ?> <?php x_get_view( 'footer', 'base' ); ?>

I also found other help topics referencing putting it in Functions.php in child theme, but my Functions.php does not reference footer or body.

Please help!
Thanks

Hello There,

Thanks for writing in! You do not need to insert it in the footer.php. All you have to do is make sure that you installed a child theme and insert the following code in your child theme’s function.php file

function amazon_affiliate_add(){ ?>

<?php // Insert the amazon affiliate ad below this line 
// =============================================================================
?>

   place the amazon affiliate ad code here

<?php // Insert the amazon affiliate ad above this line 
// =============================================================================
?>

<?php }
add_action('wp_footer', 'amazon_affiliate_add');

This method is using WordPress hooks. To know more about Hooks, action and filters, please check it in the codex: https://codex.wordpress.org/Plugin_API

Hope this helps.

1 Like