Tagged: footer, functions.php, javascript
-
AuthorPosts
-
December 17, 2018 at 8:51 pm #1046532
Hi Enfold-team
I looked through other threads like https://kriesi.at/support/topic/integrate-java-script-code-into-the-footer-before-the-end-tag/ , your documentation and a lot of info on other sites, but I don’t find a solution.
As in the thread mentioned above, I’d like to add Amazon tracking code to the footer. I tried adding it to my child theme functions.php.
But no matter what I insert, it’ll crash the site and give the error “Parse error: syntax error, unexpected ‘}’, expecting end of file in /www/htdocs/w011980a/wp-content/themes/enfold-child/functions.php on line 5” or similar ones.
I entered this code according to your documentation:
function add_amazon_associates_code_in_footer(){
?>
<script src=”//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=6938ec11-aacc-472c-XXXX-XXXXXXXXXXXXX”></script>
<?php
}
add_action(‘wp_footer’, ‘add_amazon_associates_code_in_footer’);Alternatively, I could add this asynchrous code which is recommended:
<div id=”amzn-assoc-ad-6938ec11-aacc-472c-a644-XXXXXXXXX”></div><script async src=”//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=6938ec11-aacc-472c-a644-XXXXXXXXXXX”></script>
I’d appreciate your help on this.
Thank you in advance
AnjaDecember 18, 2018 at 3:09 am #1046701Hey Aniona,
If its a script link as opposed to a script code, you could just put that into the footer.php or header.php file directly.
Best regards,
Jordan ShannonJanuary 30, 2019 at 5:20 pm #1060554Hi Jordan
Thank you. I didn’t feel comfortable writing code into the footer.php (in the main theme, I use a child theme), so I added the code as a footer widget.
This seems to work fine.Thanks and best regards
AnjaJanuary 31, 2019 at 3:20 am #1060679Hi,
Glad we could help!
Please take a moment to review our theme and show your support https://themeforest.net/downloads
Don’t forget to bookmark Enfold Documentation for future reference.Thank you for using Enfold :)
Best regards,
Vinay -
AuthorPosts
- The topic ‘Add script code to footer’ is closed to new replies.