BlogTariff


Earlier we discussed about How to add Adsense code Middle of Posts for Blogger blogs, now in this tutorial BlogTariff going to reveal the wordpress trick for adding Adsense code in the Middle of the Wordpress posts. Boosting of revenue is relavant for every webmaster but placing of ads in specific areas converts wonderful impression and bags money in your pocket. In the earlier posts we discussed about adding of Adsense code below the Post title and Adsense below posts and Adsense middle of the posts on Blogger platform. You don't need work hard just adding a code to your Wordpress template creates better way to Earn more money.

Before you do implement this trick first you need to open "Functions.php" inside your theme folder.

You may also like these below posts


How to Add "Adsense in Middle of Posts on Wordpress blogs?

Sign into your Wordpress account
Click on Functions.php file on Dashboard in theme section editor
After successful opening theme copy the below code and add after php start tag.

function inject_ad_text_after_n_chars($content) {
  // only do this if post is longer than 1000 characters
  $enable_length = 2000;
  // insert after the first </p> after 500 characters
  $after_character = 1500;
  if (is_single() && strlen($content) > $enable_length) {
    $before_content = substr($content, 0, $after_character);
    $after_content = substr($content, $after_character);
    $after_content = explode(‘</p>’, $after_content);
    $text = ‘
         <!——AdSense Code here———->

    ‘;
    array_splice($after_content, 1, 0, $text);
    $after_content = implode(‘</p>’, $after_content);
    return $before_content . $after_content;
  }
  else {
    return $content;
  }
}
add_filter(‘the_content’, ‘inject_ad_text_after_n_chars’);

Customization

Replace  <!——AdSense Code here———-> with your Adsense code only highlighted part
The   $enable_length = 2000; indicates that the Adsense Ads inserted if the post length exceeds this value and character for set location of unit in post.
We suggest the lenght value 2000 by default is best and character 1,200.

Post a Comment Gmail ID

Do not Try to Add Spam Comments

 
Top