This weekend I was having some difficulty inserting ads within the middle of a post using the plugin Simple Ads Manager. In retrospect (cutting to the chase a bit) there seems to be a setting within the Ads place setting that has the power of turning this on or off. I’ve stumbled on it by accident twice, but not able to replicate the process when I need it.
I like the plugin for managing ads in other areas of a WordPress install, just fine. Its the insertion within a post (ergo maybe 3-5 paragraphs down or something) where it gave me trouble.
So I tried to tackle things in a semi old school way. A quick Google search put me on the refresher course for inserting ads, in this example Adsense ads in a post. An article titled Adding Adsense within the Post Content – WordPress & Genesis helped quite a bit, however, I definitely did not want to follow this method on my own site.
In my case I am running a StudioPress Child theme and Genesis Framework. The code in that example provides for the creation of essentially a ‘plugin’ but one in the theme file, ergo something that hooks into the theme and alters the output.
I was already running Simple Hooks for Genesis Framework so it did not make sense to create a file to do that all over again. I just needed to find the Simple Hooks way of achieving the same result.
But I didn’t want to insert raw code, I wanted to call ads managed by the plugin Simple Ads. I don’t want someone working for me to have to go alter code that might potentially break the theme everytime they need to put a new ad in to rotation!
So I first went into Simple Hooks, navigated down to the Post/Page Hooks section and added the following code to the genesis_post_content Hook:
[sam id=5 codes='true']