Have you seen blogs that has ads inside their post content? These ads are either after the first paragraph or the second paragraph in most cases. Most beginners wonder whether these sites insert ads manually when they write the content, or if there is a special code for this. In this article, we will show you how to insert ads within your post content after specific paragraphs.
Often when beginners want to include ads in their post, they either add the code manually which is extremely inefficient specially if you have to change advertisers, or they insert ads above or below their post using one of theΒ ad management plugins.
Well, weβve been adding ads inΒ List25Β after first paragraphs, and a lot of users asked about it, so hereβs the easiest way to do it.
Simply install and activate the plugin we created calledΒ Insert Post Ads. Upon activation, the plugin will add a new menu item called Post Adverts.
Click onΒ Post Adverts Β» Add New. On the next screen, simply add the name of your ad for identification purposes, enter the ad code itself, and select the paragraph you want to display the ad code after. Once done simply click publish.
Next you want to go toΒ Post Adverts Β» SettingsΒ to select which post types you want to show your ads on such as posts, pages, and custom post types.
Now if you donβt like using the plugin, and want to do it the code way, then follow the directions below.
Open your themeβs functions.php or aΒ site-specific pluginΒ file and paste the following code:
To add your ad code, simply edit $ad_code value where it says βAd code goes hereβ on line 9. Once you do that, you are done. To change the paragraph number, simply change the number 2 to another paragraph number on line 12.
We hope that this article helped you insert ads within your post content in WordPress.
If you liked this article, then please consider subscribing to ourΒ YouTube channelΒ andΒ join us on Twitter.
Thanks toΒ @GaryJΒ for improving the code that we had.