Title: Adding ads in between posts
Last modified: August 21, 2016

---

# Adding ads in between posts

 *  Resolved [loiborg](https://wordpress.org/support/users/loiborg/)
 * (@loiborg)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-ads-in-between-posts-2/)
 * I’m trying to add advertisements after each post is shown on the front page. 
   I can’t, however, seem to find a working solution, even when following previous
   topics on the same [issue](http://wordpress.org/support/topic/adding-ads-in-between-posts?replies=10).
 * **How do I add one advertisement after each post is shown on a page?** (front
   page, archives, search results etc)
 * I’m using a child theme, so I’m not messing up original theme files.

Viewing 15 replies - 1 through 15 (of 15 total)

 *  [Verma](https://wordpress.org/support/users/vneha44/)
 * (@vneha44)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-ads-in-between-posts-2/#post-4666626)
 * You need to enter ads in loop. Look at the content.php and other similar files
   for inserting ad code.
    Remember that adsense do not allow more than 3 ads in
   single page.
 *  Moderator [Jan Dembowski](https://wordpress.org/support/users/jdembowski/)
 * (@jdembowski)
 * Forum Moderator and Brute Squad
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-ads-in-between-posts-2/#post-4666627)
 * Off topic for a minute:
 * **[@vneha44](https://wordpress.org/support/users/vneha44/)** Please stop inserting
   links to your own site in your replies. If you want to be assist people then 
   please use the Codex links instead.
 * [https://codex.wordpress.org/Main_Page](https://codex.wordpress.org/Main_Page)
 *  Thread Starter [loiborg](https://wordpress.org/support/users/loiborg/)
 * (@loiborg)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-ads-in-between-posts-2/#post-4666642)
 * Thanks for the reply, [@vneha44](https://wordpress.org/support/users/vneha44/).
   Where exactly would I put the code? [Pastebin for Twenty Fourteen content.php](http://pastebin.com/BHjReh3f)
 * Thanks for the heads up in regards to AdSense. How would I code it to only show
   up for, say, every third post?
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-ads-in-between-posts-2/#post-4666643)
 * Are you already using a [child theme](http://codex.wordpress.org/Child_Themes)?
 *  Thread Starter [loiborg](https://wordpress.org/support/users/loiborg/)
 * (@loiborg)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-ads-in-between-posts-2/#post-4666644)
 * Yes, [@esmi](https://wordpress.org/support/users/esmi/), as stated in the first
   post 🙂
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-ads-in-between-posts-2/#post-4666645)
 * Try adding your code at the very bottom of content.php in your child theme.
 *  Thread Starter [loiborg](https://wordpress.org/support/users/loiborg/)
 * (@loiborg)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-ads-in-between-posts-2/#post-4666646)
 * Thanks, [@esmi](https://wordpress.org/support/users/esmi/), that worked! I now
   have an ad showing at the bottom of each post (on the specific post page) and
   at the bottom of each post on the front page.
 * [@vneha44](https://wordpress.org/support/users/vneha44/) mentioned that some 
   ad services don’t allow you to have more than e.g. 3 ads per page. An easy way
   to fix this would be to change the settings to only show 3 posts per page, but
   that’s not a lot of posts being shown.
 * Is there a way to only show the content (ads, in this example) for every _n_ 
   post – e.g. 3?
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-ads-in-between-posts-2/#post-4666647)
 * In order to do that, you would need to add a counter into index.php which was
   incremented in content.php and then used as a conditional in the same file to
   determine whether to show an ad or not. How comfortable are you with using PHP?
 *  Thread Starter [loiborg](https://wordpress.org/support/users/loiborg/)
 * (@loiborg)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-ads-in-between-posts-2/#post-4666648)
 * Thanks for taking your time, [@esmi](https://wordpress.org/support/users/esmi/)!
   🙂
 * I unfortunately can’t code PHP, but I have some experience modifying WordPress
   files – mostly through tutorials and trial and error.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-ads-in-between-posts-2/#post-4666649)
 * Actually, I’ve come up with something a little more elegant. Have a look at [http://pastebin.com/W6sxUrbG](http://pastebin.com/W6sxUrbG)
 *  Thread Starter [loiborg](https://wordpress.org/support/users/loiborg/)
 * (@loiborg)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-ads-in-between-posts-2/#post-4666650)
 * Awesome, esmi. Thanks!!
 * Just to be difficult, is it possible to show the ad on the first post, and then
   every three? The reason I’m asking is the first solution would place an ad on
   single post pages as well, where as this solution only shows ads when there are
   multiple posts listed.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-ads-in-between-posts-2/#post-4666651)
 * for single post, and 1st, 4th, 7th post (standard post format) in an index or
   archive, try:
 *     ```
       <?php if( $wp_query->current_post%3 == 0 && (int)( $wp_query->current_post / 3 ) < 3 ) { ?>
       ADSENSE CODE
       <?php } ?>
       ```
   
 * for 2nd, 5th, 8th post, try:
 *     ```
       <?php if( $wp_query->current_post%3 == 1 && (int)( $wp_query->current_post / 3 ) < 3 ) { ?>
       ADSENSE CODE
       <?php } ?>
       ```
   
 * for 3rd, 6th, 9th post, try:
 *     ```
       <?php if( $wp_query->current_post%3 == 2 && (int)( $wp_query->current_post / 3 ) < 3 ) { ?>
       ADSENSE CODE
       <?php } ?>
       ```
   
 *  Thread Starter [loiborg](https://wordpress.org/support/users/loiborg/)
 * (@loiborg)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-ads-in-between-posts-2/#post-4666652)
 * Thanks, esmi and alchymyth – you guys are truly awesome!
 *  [tanvisule](https://wordpress.org/support/users/tanvisule/)
 * (@tanvisule)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-ads-in-between-posts-2/#post-4666669)
 * Hi i have could sucessfully get the add code
    but while placing the code in the
   text box in widget when clicked save it automatically changes to <!– Beauty –
   > <ins class=”adsbygoogle” style=”display:inline-block;width:250px;height:250px;”
   ></ins>
 * (adsbygoogle = window.adsbygoogle || []).push({});
 * something like this and this code is displayed in my site
    What m i doing wrong
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/adding-ads-in-between-posts-2/#post-4666670)
 * [@tanvisule](https://wordpress.org/support/users/tanvisule/)
 * your problem is different from the question of this topic.
    [http://codex.wordpress.org/Forum_Welcome#Where_To_Post](http://codex.wordpress.org/Forum_Welcome#Where_To_Post)
 * please continue with your own topic at [https://wordpress.org/support/topic/help-with-word-presss-n-google-adsense?replies=1](https://wordpress.org/support/topic/help-with-word-presss-n-google-adsense?replies=1)

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Adding ads in between posts’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/twentyfourteen/4.5/screenshot.
   png)
 * Twenty Fourteen
 * [Support Threads](https://wordpress.org/support/theme/twentyfourteen/)
 * [Active Topics](https://wordpress.org/support/theme/twentyfourteen/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/twentyfourteen/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/twentyfourteen/reviews/)

## Tags

 * [ads](https://wordpress.org/support/topic-tag/ads/)
 * [advertisement](https://wordpress.org/support/topic-tag/advertisement/)

 * 15 replies
 * 6 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/adding-ads-in-between-posts-2/#post-4666670)
 * Status: resolved