Insert ads between comments in WordPress

Recently I noticed that several of my sites on WP have turned into forums) in other words, users began to use the comments to communicate among themselves. I certainly do not mind, let them communicate. But to benefit from it, I find it too:-)

To do this, we will make a script to insert the content code after a certain number of posts.

Changes will make the file comments.php our WP themes.

1. First determine the interval.

Insert at the beginning of the file

Would mean that each 10-m comment will insert our code

Or a more advanced variant, where the number of blocks on a page is limited, as all major systems of contextual advertising. Here’s an example of when you want to display the block across the context 4 port├ónke comments through the equal span, but the interval is not less than 10 to not spam the page context.
php? $cherez = < ceil (get_comments_number ()/5); If ($cherez < 10) $cherez = 10; >?

2. View comments

Look for the line

The plugins

And then after insert

3. display of advertising

Insert before code such as the following:
our code

Our code

Our code-replace your ad code.