WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] How add 2 adsense (below the first and second post) in main page or category?

[Resolved] How add 2 adsense (below the first and second post) in main page or category?

  • Hi.
    I want to add 2 google ads in main page or in category: one adsense below the first post and one adsense below the second post.

    I use this code:
    <?php $count = 1; ?> /* before <?php if (have_posts())... */
    and after this

    <?php if ($count == 1) : ?>
    code adsense
    <?php endif; $count++; ?>

    and so, I have a adsense below the first post, but I want also another adsense below the second post.

    How?
    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Sorry,
    I found the solution.

    Before this: <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    I put this:

    <?php
    $postnum = 1;
    $showadsense1 = 1;
    $showadsense2 = 2;
    ?>

    Before this:<?php endwhile; else: ?>
    I put this:

    <?php if ($postnum == $showadsense1) {
    echo '
    code adsense
    ';
    } ?>
    
    <?php if ($postnum == $showadsense2) {
    echo '
    code adsense
    ';
    } ?>
    <?php $postnum++; ?>

    Hi Erfo,

    I posted a video tutorial on how to do this. The video can be found here: http://www.wpcontent.com/post/190.

    I hope that helps,
    Eric

    Works like a charm! Thanks a lot.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] How add 2 adsense (below the first and second post) in main page or category?’ is closed to new replies.
Skip to toolbar