free html hit counter
Create Adsense shortcode for WordPress
Create Adsense shortcode for WordPress
2017-10-09 / Dimas Lanjaka Kumala Indra

Create Adsense shortcode for WordPress

  1. Go to Your Dashboard WordPress
  2. Click menu -> Appearance
  3. Click editor -> choose functions.php
  4. 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
*/

Create Adsense shortcode for WordPress

PermaLink: https://www.webmanajemen.com/2017/10/create-adsense-shortcode-for-wordpress.html
Incoming search terms for Create Adsense shortcode for WordPress:
  • Create Adsense shortcode for WordPress
  • Create Adsense shortcode for WordPress WMI Gitlab

Google Rich Snippets | Schema Markup Validator | Google Pagespeed Insight