WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Wordpress Swift Theme is installed on my My site http://tech-ticks.info

From last few days, I am trying to find a solution to put an ad banner on homepage only between post1 and post 2. I have already tried on worpress support forum.

Can anyone here help me out as i don't have much knowledge about PHP.

Your help will be highly appreciated.

share|improve this question
You will not to post some code or a better example , please have a look at wordpress.stackexchange.com/faq – Wyck Jan 11 '13 at 17:13

Register a widget, and call it on the front-page when the the_post action is called second time:

add_action( 'wp_loaded', 'wpse_80202_register_banner_widget' );
function wpse_80202_register_banner_widget()
    // used on the first page of main loop only
        array (
            'name'          => 'Banner front-page ',
            'id'            => 'frontpage_banner',
            'before_widget' => '<div class="frontpage-banner">',
            'after_widget'  => '</div>'

add_action( 'loop_start', 'wpse_80202_show_banner_widget' );

function wpse_80202_show_banner_widget()
    static $count = 0;
    if ( ! is_front_page() )

    if ( 'loop_start' === current_filter() )
        add_action( 'the_post', __FUNCTION__ );

    $count += 1;

    if ( 2 === $count )
        dynamic_sidebar( 'frontpage_banner' );
        remove_action( 'the_post', __FUNCTION__ );

I would use the Text widget for that:

enter image description here

Another variant of this code here: Add Adsense code in index.php

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.