I want to insert an ad code in the middle of a post via
I found several links but either they don't use
functions.php or don't insert the code in the middle.
Can anyone tell me how to do this?
Also, I don't want to use a plugin.
This function inserts your ad code after the specified paragraph.
There are several alternatives:
First, you can use shortcodes as @iambriansreed suggest, but you need to know PHP programming to register the shortcode. The following code is from a website (in spanish) that shows how to program a simple shortcode with Adsense:
Second, you can use a plugin like Quick Adsense to achieve the same shortcode but easily customizable or let the plugin select where to put the ads.
And finally, you can write your own code to add ads at n-th paragraph (i.e. exploiting each paragraph and selecting the n-th paragraph and add there your ads code). It's not the best solution but it will be fully customizable.
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?