Amazon Affiliates oneTag

I’d like to insert the Amazon Affiliates program oneTag at the end of the body element as Amazon recommends. I have a child theme set up.

I tried to copy /pro/framework/views/footer/base.php to /pro-child/framework/views/footer/base.php.

Even without changing anything within base.php, the entire footer section of the website disappears. There’s still a closing body and html tag, but the footer contents themselves are absent.

Do I have to do anything besides copying base.php in order to edit it?

Thanks!

Hi There,

Please delete that file and add the following code under functions.php file locates in your child theme instead:

add_action( 'wp_footer', 'x_insert_footer_scripts' );
function x_insert_footer_scripts(){
	?>
	<!-- Your code will go here! -->
	<?php
}
1 Like

Glad I found this thread.

Just to make sure I’m doing it right, do you mean to replace only “Your code will go here!” and not “!-- Your code will go here! --” (without the quotes)?

After inserting into functions.php in child theme how do I check if the code is properly inserted?

Thanks
Martin

Hi there,

You should replace the entire line <!-- Your code will go here! --> with your own code. Or simply add it under that line, it’s just a dummy/comment text which will not be displayed.

And to confirm if it’s added, simply load your site in your browser then right click the page and click View Page Source, then you should find your added code if you examine it.

Thanks!

Thanks for your reply. Appreciate.

Glad we could help.

Cheers!

I tried to follow this same process but it didn’t work - I believe because I don’t use the child theme, I have the X theme.

Would yous be able to help?

Cheers

Hi @Lyle_MacLeod,

Thanks for writing around! You’ll need a child theme for the above customization. To setup child theme please follow https://theme.co/apex/forum/t/setup-how-to-setup-child-themes/57 and then add the above code in your Child Theme’s functions.php file.

Hope this helps!

Thanks man, I’ll give that a try!

But is there anyway I could add the code without using the child theme?

Hey there,

Unfortunately there is no other way!

Thanks!

Cool no worries, thanks for the help!

You’re welcome.

That still didn’t work.

All I got was a message saying: “Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP”

Could yous show me how to do that?

Hi there,

You saw the warning because there was some kind of error (code error/ syntax error) with the code you tried to add. Please make sure you replace this line <!-- Your code will go here! --> with your custom script and not change anything else.

Best regards.

I’m sure I entered the correct code, but I’ll try again

Let us know how it goes. :slight_smile:

Inside the editor, where exactly do I paste the code into?

At the end or directly below “Additional Features” or somewhere else?

Put it under Additional Functions.

If you still encounter a fatal error, please try this method so you don’t mess with PHP which is the cause of fatal errors. Either way though, this requires third party code or a plugin so issues arising from this is outside the scope of our support. We already gave the way for you to add your code and it will work provided that it was implemented correctly.

Thank you for understanding.