AD sense script

Hey guys! how are you ?
I need to ask you if you can help me to insert the ad sense script in the head of my page but I cannot find it. I saw on another discussion thread that you have suggested to use the insert headers and footers plug in but their last update was 8 months ago… not sure if this is ok…

can you please help? thanks a lot
cheers

Hi,

You can use the theme’s hooks to add your script.

eg. Add this in your child theme’s functions.php file.

function add_adsense() { ?>

 // ADD YOUR ADSENSE CODE HERE

<?php
}

add_action( 'x_before_site_begin', 'add_adsense', 10 );

For more information, kindly refer to the link below

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

Hello Paul, thank you so much for your detailed reply but I have no idea where to find the functions.php.
could you please give me guidance :slight_smile:

thanks a lot
cheers

Hi,

Please see screenshot

thanks Paul
I did it and i got this message. please see screen shot attached

could you please help? thanks a lot
have a great day

Hello @isa1978,

Looking at the screenshot it seems that you have directly pasted the JS code in function.php file. Please use the solution mentioned by my colleague and in place or after // ADD YOUR ADSENSE CODE HERE you are suppose to paste the Adsense code. If you are not comfortable with plugins there are bunch of readily available plugins that can be used to implement Google Adsense. As you mentioned I checked Header and Footer plugin and it’s been quite sometime that developers has not updated the extension. However you can take a look at following plugin:

  1. Plugin Name: Head, Footer and Post Injections
  2. Download URL: https://wordpress.org/plugins/header-footer/
  3. Tutorial: https://pagely.com/blog/safe-easy-way-add-code-wordpress-websites-header-footer/

You can also take a look at:

  1. Plugin Name: Insert Header and Footer
  2. Download URl: https://wordpress.org/plugins/insert-headers-and-footers/
  3. Tutorial: http://www.wpbeginner.com/plugins/how-to-add-header-and-footer-code-in-wordpress/

Thanks.

Hello there! I had a look at the screen shot already but I did exactly the same as the screen shot above was mentioning. The only think is that I had already another addictional function there so I have pasted the adsense below that. I have downloaded one of the plug ins tht you mention and it seems to work. thanks a lot for now
cheers
Isabella :slight_smile:

Glad to hear that, feel free to get in touch with us regarding any queries about the Pro, X|Theme and Cornerstone.

Cheers :slight_smile:

1 Like

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