How to add Google Adsense in WordPress child theme

To insert ads into a child theme on an Adsense site: add the following code to function.php:

///Google AdSense:
add_action('wp_head', 'wpse_43672_wp_head');
function wpse_43672_wp_head(){
    //Close PHP tags 
<script data-ad-client="ca-pub-<publisher-numberic-code>" async src=""></script>
    <?php //Open PHP tags

Don’t forget to replace the publisher’s numeric code (also removing the angle brackets around it).

But in general it is more convenient to insert this code through a wordpress widget 🙂

This entry was posted in Wordpress (en). Bookmark the permalink.

Leave a Reply

🇬🇧 Attention! Comments with URLs/email are not allowed.
🇷🇺 Комментарии со ссылками/email удаляются автоматически.