Install Adsense Code where exactly in header

Hi there,

I suggest that you add the code below to the functions.php file of your Child Theme as it is more standard and better way to add a custom script to the header:

add_action('wp_head', 'head_assets_2', 9999);

function head_assets_2 () { ?>

<?php }

Add the code above after:

// Additional Functions
// =============================================================================

Insert your code between function head_assets_2 () { ?> and <?php }.

For more information kindly read this article:

https://theme.co/apex/forum/t/customizations-actions-and-filters-in-x/208

Thank you.

Ty Christopher,

Where do I find the child theme?

Hi there,

You can download your child theme in your dashboard here in forum/Apex. Go to your forum profile then go to PRODUCT LINKS section and click Go to Child Themes. And you may download it there.

Cheers!

Almost…any suggestings

Hello There,

I do not see anything wrong with the code. Is your child theme active? It should have been applied it the child theme is active. Would you mind providing us the url of your site so that we can investigate?

Thank you in advance.

Hi there,

I am thinking, isn’t it an ad embed code? Maybe there is a confusion between analytics and Adsense. Analytics can be added to the header and footer, but Adsense should be in content part. Or perhaps you wish to add an ad to your header bar (not html head)?

It will not really work since you’re placing your ads in HTML head. What part of the header bar you wish to display your ads?

Thanks!

Hi Rad
I’m stuck in the sense that in my adsense account embed code that google provided to place “into the HTML of my site between the head and head tags” doesnt save correctly. I cant get google to review the site so to speak becasue the code wont even upload.
The problem seems to be that I cannot get my Xtheme to allow this addition. When I past he code, I get an error when I try to upload the code. Ty

Hi there,

Would you please kindly be more specific on what you do and what is the error you get? How you change the code and upload that you see the error?

We need to have more information to see what is the problem as we already suggested that what you should do but it seems that it is not implemented correctly.

Thank you.

Hi Christopher,
I now have the child theme
I take the code you provided and add the adsense embed code
I have attached the error I’m getting when I attempt to update file (see pic)

Hi there,

Please make sure that you do not miss to add the <?php } after the last </script> in the code.

If the code is complete and you are still having the error, please provide the admin and the ftp details of your site in a secure note so that we can check it.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.

Hello Matthew,

I request you to please create a new ticket and give reference to this ticket for faster response time.

Thanks.