Advertisement
  • Replace YOUR ADSENSE CODE OR OTHER ADDS CODE LINK HERE with your own Adsense or any ads code.
  • Save and check your blog post to see if it works.
  • b) By editing functions.php

    function inject_ad_text_after_n_chars($content) {
      // only do this if post is longer than 1000 characters
      $enable_length = 1000;
      // insert after the first  after 500 characters
      $after_character = 500;
      if (is_single() && strlen($content) > $enable_length) {
        $before_content = substr($content, 0, $after_character);
        $after_content = substr($content, $after_character);
        $after_content = explode('', $after_content);
        $text = '
         <!-- YOUR ADSENSE CODE OR OTHER ADDS CODE LINK HERE -->
       ';
        array_splice($after_content, 1, 0, $text);
        $after_content = implode('', $after_content);
        return $before_content . $after_content;
      }
      else {
        return $content;
      }
    }
    add_filter('the_content', 'inject_ad_text_after_n_chars');

    2.Adding Adsense code with the help of plugin
    You can also add Adsense display ads by using free WordPress plugin. There are many ad manager plugins. You can try any one. Here are some that I found useful and easy to use.