- Go to Your Dashboard WordPress
- Click menu -> Appearance
- Click editor -> choose functions.php
- Add below code inside <?php
/*
* enqueue adsbygoogle.js in the footer &
* create a WordPress shortcode with your Google AdSense code
* follow me on Twitter: @DimasSkynetCybe
*/
function loadAdsenseJS() {
wp_register_script( 'google-adsense', '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js', '', '', true );
wp_enqueue_script( 'google-adsense' );
}
add_action( 'wp_enqueue_scripts', 'loadAdsenseJS' );
function AdSense() {
$output = '<ins class="adsbygoogle"
style="background-color: transparent;
text-decoration: none;
display:inline-block;
width:336px;
height:280px"
data-ad-client="ca-pub-xxYourUniqueIdxx"
data-ad-slot="xxUniqueIdSlotxx"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>';
return $output;
}
add_shortcode( 'adsense', 'AdSense' );
/*
* Usage: add [adsense] in your WordPress posts
* where you want your ad to appear
*/
Comments
Post a Comment
Bila Ada posting yang kurang, atau error atau yang lainnya, silahkan tinggalkan komentar agar artikel/post di perbaiki.
Jangan Lupa Cek Box "Notify Me" agar tahu komentar kamu dibalas oleh saya.
If there are any posts that are missing, or error or anything else, please leave a comment for the article / post to be fixed.
Do not Forget Check Box "Notify Me" to know our comments replied by me.