Viewing 12 replies - 1 through 12 (of 12 total)
  • – you can edit the template by hand. if you have any php experience, usually the best route.
    – you can get an adsense-specific management plugin. sometimes gets too complex.
    – you can get CG-Inbetween, which lets you generically insert an html include file (say, your adsense code) at an ‘offset’ you specify. also can specify multiple offsets (say 2,5,8), the end of the page (‘last’), etc.

    -d

    In your theme’s index.php:

    Look for The Loop:

    <?php while (have_posts() : the_post(); ?>
    ...
    <?php the_content('...'); ?>
    ...
    <?php endwhile; ?>

    and change to:

    <?php while (have_posts() : the_post(); ?>
    ...
    <?php the_content('...'); ?>
    ...
    <?php $postcount++; ?>
    <?php if ($postcount++ == 2) { ?>
    your adsense code goes here
    <?php } ?>
    ...
    <?php endwhile; ?>

    Just make sure you don’t screw up the layout by placing your adsense code in the wrong div etc.

    With CG-Inbetween, the mods above get boiled down to:
    <?php inbetweenPosts(); ?>

    Then the admin panel allows you to create and control multiple Inbetweens, which can ‘echo’ text, include a php or html file (perfect for adsense), or call a one-shot php function. All three are great to add more to your site without constantly changing the theme files (one line, and you are set). It’s also REALLY useful if you have multiple themes (theme switching) as you add that one line to each theme, and then they all inherit the same Inbetween rules.

    Anyway, ping if you have Qs.

    -d

    David when we add in between all we have to do is past that code in then? Or can we just put the plug in then go

    With CG-Inbetween you need to put that one line into your template/theme. The reason is that it isn’t usually ‘appropriate’ to just throw extra stuff onto the end of the article content (one of the few easy places that would make sense). It is better for the user, theme designer, etc. to add the inbetweenPosts call where it is most appropriate for the theme. Usually you’d want it just at the end of the post, before the closing DIV.

    I considered other auto-insertion options, like spitting it out as each post started (or ended) processing — the problem with that is the inserted stuff wouldn’t be inside the post DIV — ostensibly not a huge deal, but much easier IMHO to style it within the post content area.

    -d

    So before like the feedback DIV would be the appropriate place for it?

    thanks for your help btw

    Here is where I placed it:

    <div class=”feedback”>

    <?php edit_post_link(__(‘Edit This ·’)); ?> <?php comments_popup_link(__(‘No Comments’), __(‘1 Comment’), __(‘% Comments’)); ?>

    </div>

    <?php inbetweenPosts(); ?>

    <?php wp_link_pages(); ?>

    I have it programed in with an html feed for after the first post put it is not showing up. I am sure I have it plugged into a poor spot.

    Without seeing your site/theme, I’d say: try an Echo Inbetween, see where it shows up. ??

    -d

    The page: https://kevin.pointlessbanter.net

    I moved it before the:
    <?php endwhile; ?>
    Tag

    There is a gap there in between the two posts and when I right click on it is says that it is google. But it gives me an error on page message in the bottom and the actual add isn’t showing up.

    Thanks again
    -Kevin

    Ummm… I can see that page, and there’s a Google ad at the end of the first post. Is that using CG-Inbetween?

    Before the:
    </div> <!– Closes the post div–>
    .. is the place you likely want it. You can put it before the ‘feedback’ div too.

    Alternately, you can put it AFTER the closing of the post div, to have it outside the physical post box — but I prefer it inside.

    Note that you can only have 3 ad units per page, and I’m not sure whether SiteSearch counts or not. It’ll just stop displaying after the third one.

    Also note from a search-engine standpoint, all your sidebar stuff comes BEFORE your main content, so the less-interested crawlers may not do a good job indexing your site given how much sidebar stuff you have… ??

    What’s the deal with quote handling on CG-Inbetween? I can’t make it display Adsense because every time there’s a quote in the code (e.g. “https://…&#8221;) it adds a \ in front of the quote. Workaround?

    Yep, just use the ‘include’ inbetween, i.e., include something like ‘adsensewide.htm’ with the adsense code. echo is meant for simple text (at the moment). not to mention that if you want to say do after post 2 AND after all posts as two different inbetweens, they can include the same htm file.. ??

    -d

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Putting adsense between 2 and 3 post on frontpage’ is closed to new replies.