BW WordPress Theme: Add Google Adsense Unit

If we want to add advertisment into ours site which using BW WordPress Theme so here is some suggestions.

Add styling in style.css like this, for example we named the div “ads” for ads at widget and “adsense” for ads at body and content.

.textwidget .ads {
margin: 5px 0 5px 0;
text-align: center;
}
.adsense {
display: block;
text-align: center;
color: yellow;
background: gray;
margin-bottom: 10px;
}


In widget, we use the text widget and put the style and ads code like this.
<div class="ads">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-85441456939xxxx";
/* 300x250 */
google_ad_slot = "5515853486";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

If we want the ad display on the top so we put the code into the header.php after <div id="main" class="site-main"> like this.
<div id="main" class="site-main">
<div class="adsense">
<p>728 x 90 px Google Adsense unit</p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-85441456939xxxx";
/* lebar */
google_ad_slot = "9739830688";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

The difference between using style and without style.
add adsense in BW

ad unit with BW theme
The ad unit withoout div.
ad unit in BW theme
ad on top with style.

To place the ad after or at the end of the post content we put the code into content-single.php after <div class="entry-content">
<?php the_content(); ?>
like the example below.


<div class="entry-content">
<?php the_content(); ?>
<div class="adsense">
<p>468 x 60 px Adsense Unit</p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-8544145693xxxx";
/* SM-JB-46860-text */
google_ad_slot = "4244064681";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<?php

adsense in BW theme
Ad unit after the post content.

Than, if we want the ad display below the post collumn so we ad the code after <?php get_template_part( 'content', 'single' ); ?> and before <?php black_white_content_nav( 'nav-below' ); ?> on single.php.


<?php get_template_part( 'content', 'single' ); ?>
<div class="adsense">
<p>468 x 60 px Adsense Unit</p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-85441456939xxxx";
/* SM-JB-46860-text */
google_ad_slot = "4244064681";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<?php black_white_content_nav( 'nav-below' ); ?>

ad in BW theme

The last one is display the ad above footer. On footer.php after </div><!-- #main --> and before <footer id="colophon" class="site-footer" role="contentinfo">.

</div><!-- #main -->
<div class="adsense">
<p>728 x 90 px Google Adsense unit</p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-85441456939xxxx";
/* lebar */
google_ad_slot = "9739830688";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<footer id="colophon" class="site-footer" role="contentinfo">

ad in BW theme

Iklan

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google

You are commenting using your Google account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s