Guide to insert Google Adsense code at the end of the article

Guide to insert Google Adsense code at the end of the article

As in the previous Vinadomain instruct you how to: Insert Google AdSense into Post WordPress. Now will be the 2nd insert.

Use code and inserted at the end functions.php and save.

Ext:

function yourprefix_add_to_content( $content ) {

if( is_single() && ! empty( $GLOBALS[‘post’] ) ) {

if ( $GLOBALS[‘post’]->ID == get_the_ID() ) {

$content .= ‘<p><script async src=”https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
<!– DLN-Bai Viet –>
<ins class=”adsbygoogle”
style=”display:block”
data-ad-client=”ca-pub-8283623466596884″
data-ad-slot=”5213817285″
data-ad-format=”auto”
data-full-width-responsive=”true”></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>’;

}

}

return $content;
}
add_filter(‘the_content’, ‘yourprefix_add_to_content’);

by your code.

Good luck for you.

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *

3 × three =