Add Widget After Post In Loop

This code enables you to add a new widget area after the 1st post on the home page archive.

This is a popular spot to add Adsense code and affiliate advertising banners as it displays in the same position after new posts are published.

Adsense code also works great in text widgets and its better to add HTML in a widget rather than hard code it into a custom file or template file.

after-1st-post

The code is easy to customise so you can use on any other type of archive simply by changing the conditional tag.

If you want to add the widget after the 2nd or 3rd post, you can, simply by modifying a single number in the code. Its as easy as that.

Here’s the PHP code you simply copy and paste into your child theme functions file.

4 responses to “Add Widget After Post In Loop”

  1. […] Add New Widget After 1st Post On Home Page […]

  2. […] Add Widget After Post Excerpt on Archive […]

  3. […] Add Widget After First Post In Archive Loop […]

  4. […] Add New Widget After Post In Home Page Loop […]

Was This Tutorial Helpful?

Free

$0

Access only to all free tutorials per month.



Monthly

$75

Access to 10 premium tutorials per month.


Tutorial Request


Includes code guarantee and coding support.

Yearly

$500

Access to 15 premium tutorials per month.


Monthly Tutorial Request


Includes code guarantee and priority coding support.