How to Add Google Adsense ads After/Before the Post Title in Thesis Theme

Gowtham V
3 Min Read

Hai friends..Adsense is one of the best way to earn money online .You can add adsense code to thesis theme easily by using thesis hooks.Here is a Short tutorial on How to Add Google Adsense After/Before the Post Title in Thesis WordPress Theme

Thesis 1.x : Follow this tutorial only if you are using thesis 1.x theme.

Thesis 2.x : If you are using the latest version of thesis , then you can use Quick Adsense Plugin to add ads to your theme.

How to Add adsense ads after Post Title:

 Google Adsense adsBefore the Post Title

#Create an Adsense ad of 300×250 size in Myads tab in adsense dashboard and click on get code

#Open your custom_functions.php of your thesis theme by using Filezilla or through the Custom File Editor under Thesis options

#Backup your file before you add the adsense code

#Now copy and paste the below code into the php file

/*Adsense ads after post title */
function adsense_ads_after() {
if (is_single()) {?>
<script type="text/javascript"><!--
google_ad_client = "pub-adsense";
/* MtsPost300x250 */
google_ad_slot = "adds";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="https://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<?php }
}
add_action(‘thesis_hook_after_post’, ‘adsense_ads_after’);

#Now replace the codes in red with your adsense ad unit code.

#Save the file and refresh your page.Your adsense ads will be shown

right after the post title

Note:The ads will take 10 to 20 minutes to appear in your blog.

How to Add adsense ads Before Post Title:

#Just change the thesis hook name as thesis_hook_before_post instead of 

thesis_hook_after_post

#Here is the code to ad Before post tit/*Adsense ads after post title */

function adsense_ads_before() {
if (is_single()) { ?>
<script type=”text/javascript”><!–google_ad_client = “ca-pub-…..”;
google_ad_slot = “………”;
google_ad_width = 336;
google_ad_height = 280;
//–></script>
<script type=”text/javascript”src=”https://pagead2.googlesyndication.com/pagead/show_ads.js”>
</script>
<?php }
}
add_action(‘thesis_hook_before_post’, ‘adsense_ads_before’);

#Simply copy and paste with your ad code to the custom_functions.php file as mentioned above.

#Save the file

This post is a part of Thesis Customization Tutorials .Hope you have successfully added adsense to your blog post after or before title.

If you have any errors in adding the code,notify us  in the comment section we will help you 🙂

Share This Article
9 Comments
  • Dear sir, I am using thesis theme and show adsense code below post title. But it is safe if I could draw a line right after post title that could distinguish post title and ads. This is done to escape from google banned. Would you please advise me how could i place a line between post title and ads?

    • Drawing a line after the Ads will not get you banned.You can implement the line after post title by using the custom.css file .Thanks.Do visit again

    • To add adsense after post to wordpress theme , you can use plugin such as Quick Adsense to add ads at different places of your blog.Thanks Exinco for your valuable comment.

Leave a Reply

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