Thesis Theme, Guide To Add Adsense After The Title & After The Post

by Abi on October 3, 2009

If you want to add an ad (such as Adsense, Chitika or any ad) inside your single page right beneath your title or after the post then you need to add an additional codes to your custom_functions.php, because in Thesis whenever you want to modify its look or to adding anything you need to edit your Custom_Function.php file and to form its look you need to modify or adding some css code inside your custom.php, it’s extremely different with standard WordPress Theme procedure which requires you to dig into your Theme Editor. That’s the main idea of Thesis theme to keep you away from it.

How To Display Ads Beneath Title Post & After The Post

The thing you need to do now head to custom_functions.php and add the following code inside it:

Here’s the code to add an ad right after the title

function before_post_ads() {
if (is_single()) { ?>
Your Ad Code Here !
<?php }
}

add_action('thesis_hook_before_post', 'before_post_ads');

Let’s say you are adding Google Adsense, it should look like this:

function before_post_ads() {
if (is_single()) { ?>
<script type="text/javascript"><!–
google_ad_client = "pub-XXXXXXXXXXXXXX";
/* 250×250, created 8/17/09 */
google_ad_slot = "XXXXXXXX";
google_ad_width = 250;
google_ad_height = 250;
//–>
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<?php }
}

add_action('thesis_hook_before_post', 'before_post_ads');

And the following is the code to add an ad right after the post

function after_post_ads() {
if (is_single()) { ?>
<?php }
}

add_action('thesis_hook_after_post', 'after_post_ads');

And it should look like the following:

function after_post_ads() {
if (is_single()) { ?>
<script type="text/javascript"><!–
google_ad_client = "pub-XXXXXXXXXXXXXX";
/* 250×250, created 8/17/09 */
google_ad_slot = "XXXXXXXX";
google_ad_width = 250;
google_ad_height = 250;
//–>
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<?php }
}

add_action('thesis_hook_after_post', 'after_post_ads');

How To Align The Ad Inside Thesis Post

And if you want to align the position of the ad to the right or to the left, you can simply add the following css code:

If you want it appears on right side of first paragraph


<p style="float: right;margin: 4px;">

And the complete code should look like this: (See at the bold parts)

function before_post_ads() {
if (is_single()) { ?>
<p style="float: right;margin: 4px;">
<script type="text/javascript"><!–
google_ad_client = "pub-2176591172991554";
/* 250×250, created 8/17/09 */
google_ad_slot = "2077149963";
google_ad_width = 250;
google_ad_height = 250;
//–>
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<?php }
}

add_action('thesis_hook_before_post', 'before_post_ads');

That’s it! You are free to choose to add the ads anywhere inside your Thesis Theme’s single page.

Note: Thesis is a great theme that is highly recommended by many top bloggers and SEO gurus, if your blog is not using Thesis, may be it’s time to consider using it or may be purchase it directly via my affiliate link.

I hope this post helps you and see you in the next post!

Related posts:

  1. How To Move Thesis Main Navigation Below Header
  2. With Thesis Theme You Got A Complete Control And SEO Theme
  3. Education WordPress Theme By StudioPress & Joost de Valk
  4. How To Make WordPress Theme SEO Friendly Theme

{ 1 comment }

Career Target October 7, 2009 at 9:59 am

Thanks for posting this trick. I will apply this into my adsense.

Comments on this entry are closed.

{ 1 trackback }

Previous post:

Next post: