Support » Themes and Templates » Editing post template

  • The theme I’m using has a single post page (single.php). I use Adsense Deluxe and WP Ads on my site and I’d like to edit the theme so that the plugin calls (ie <!–adsense–>) are included automatically on each post. The goal is to be able to edit the ad placement on each post without having to edit all 450 posts by hand.

    Any help is appreciated!

Viewing 1 replies (of 1 total)
  • To append <!--adsense--> to the end of EVERY post that doesn’t already have it, you can use this little piece of code. I haven’t tested it, but it should work. Put it in one of these:

    1) Your theme’s functions.php
    2) The end of the adsense deluxe or wp ads plugin file
    3) Into a blank PHP file, with a plugin header at the top of the file, and then activate it as a new plugin

    function adsensify($content){
      if (false!==strpos($content,'<!--adsense-->'))
        return $content;
      return $content . "\n\n<!--adsense-->";

    Note that the <!--adsense--> thing won’t show up when you edit posts–it gets appended right before the post gets displayed on your site.

Viewing 1 replies (of 1 total)
  • The topic ‘Editing post template’ is closed to new replies.