Code Snippets

Add Google Content Ads Between Your WordPress Search Results

I have been thinking about the best way to display ads on my WordPress blog search results for a long time because there are numerous options. You could just display content ads at the top, bottom, or both locations, you could add a WordPress plugin, or you could create a custom page with Google custom search results geared for your page. I played around with the latter two options but wasn’t happy with eaither result. One of the ways to do the Google custom search results is using an iFrame and iFrames suck. Anyway I decided to add some custom PHP code to display the ads however I ran into a problem quickly which was the fact that you can only display 3 of the same ad on any one page so if you want to display ads in between each search result it would get a bit more tricky.