• If I wanted to display an adsense banner on the home page, but only after the most recent post, what would i need to wrap the adsense code in?

Viewing 9 replies - 31 through 39 (of 39 total)
  • i’ve used this code in a couple of websites without any problem but now i have a website with two wp installations (two languages) and it works in the spanish one but not in the english one! i have revised the code around it and in the header of the template a dozen times and they look identical! take a look:

    https://www.clubsonyericsson.com/es
    https://www.clubsonyericsson.com/en

    Cool it worked. I used the code that was in the near the beginning of this thread. I now have my adsense code between posts 1 and 2. How would I tweak the code to have the “adsense code” appear between posts 2 and 3 ALSO…. ??

    Thanks

    Ok this is what I actually have in my index. I can change the $showads to any number I want to indicate which post to show the Ads after. But, I want to show it after post 1 and after 2…

    I can’t seem to find this anywhere.. ideas??

    <?php
    get_header();
    ?>

    <?php $postnum = 1; $showads = 1; ?>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    <div class=”post”>

    <h3 class=”storytitle” id=”post-<?php the_ID(); ?>”><div id=docimage></div>” rel=”bookmark”><?php the_title(); ?></h3>
    <div class=”meta”><?php _e(“Filed under”); ?> <?php the_category(‘,’) ?> <?php _e(‘by’)?> <?php the_author() ?> on <?php the_time(‘l F j, Y’); ?> <?php edit_post_link(__(‘Edit This’)); ?></div>

    <div class=”storycontent”>
    <?php the_content(__(‘(more…)’)); ?>
    </div>

    <div class=”feedback”>
    <?php wp_link_pages(); ?>
    “>Trackback · <?php comments_popup_link(__(‘No comments yet’), __(‘1 comment’), __(‘% comments’)); ?>
    </div>

    <?php trackback_rdf(); ?>

    </div>

    <?php comments_template(); // Get wp-comments.php template ?>

    <?php if ($postnum == $showads) { ?> ADSENSE CODE HERE <?php } $postnum++; ?>

    <?php endwhile; else: ?>
    <?php _e(‘Sorry, no posts matched your criteria.’); ?>
    <?php endif; ?>
    <div class=”feedback”><?php posts_nav_link(‘ — ‘, __(‘« previous page’), __(‘next page »’)); ?></div>

    <?php get_footer(); ?>
    <br><br>

    hmmm… maybe it isn’t possible. I thought I saw this on another WordPress script but maybe it was a different script…

    I tried the original solution on this thread, as proposed by Techgnome here.

    Of course implementing them at the corresponding parts of the new loop, in index.php

    However, although my Google Ads do appear fine between the first and second posts, they do NOT appear on my sidebar or footer. If I remove the code, my sidebar and footer ads show up fine.

    In particular there should be google links at the footer and a vertical google ad on the sidebar, as well as a half banner google ad at the top-right hand box. That’s 3 ads, and 1 link, exactly what adsense allows…

    So I cannot understand why they show alternate (amazon) ads instead, or nothing (in the case of the sidebar box, where I don’t have alternate ads enabled).

    If you visit an individual post’s page (making use of a single.php file not including the $showAdSense solution), everything displays as it is meant to.

    I am very confused over this, anyone has any suggestions?

    You can see my blog here. Thanks!

    I have tried almost everything to get ads in the title, under the “Comments” link. When I add the adsense to post.php, it adds it to the first two posts. Any ideas? I just want it on the first post.

    Thanks

    opioq

    (@opioq)

    I have been looking for this post!
    I am trying to place an adblock above the fisrt post but not above the <div id=”content”> which was mentioned earlier, doing that pushes my side colums down. Any suggestions? I would greatly appreciate it.

    I am also seeing ads inside of posts in differant colors.

    You can see my site here to know what I am talking about.

    thanks.

    I’m trying to do this, but using the adsense deluxe plugin, what ends up happening is that the <!–adsense#bigbox–> just gets put into the resultant page, the plugin doesnt translate it to the actual adsense code.

    Is there soemthing I have to put around this to get it to do the translation or will this never work?

    No clue…. I don’t bother with any of the plugins, I just put the code where it needs to be. I’ve never seen any point to the plugins.

Viewing 9 replies - 31 through 39 (of 39 total)
  • The topic ‘Adsense after first post only’ is closed to new replies.