Support » Plugins » Moosecandy / Adsense

  • I’m having a bit of trouble with this plugin.

    Basically, what I want is to have some Adsense code inserted below the first post (or above the second post) on the main page of my blog. I’ve read the instructions and installed the plugin OK, but when I paste the code into where I think it should go in my index.php nothing happens.

    PHP is a mystery to me, but I’ve tried <?php $candy[2] = 'The Moose is Loose!'; ?> – is that wrong?

    Obviously I will put the adsense code in once I figure out what I’m doing wrong…

Viewing 12 replies - 1 through 12 (of 12 total)
  • Why do you need the plugin to get Adsense working? I’ve got it going fine on my site ( without any plugin required. why don’t you just include the required code in your index.php file?


    Uhm, you shouldn’t paste ANY code into index.php if you are using MooseCandy, that’s the whole point of it.

    Once you set $candy[2] = ‘The Moose is Loose!’; in the plugin file, you should see that text between post 1 and post 2.

    I know this plugin will work with AdSense because it is derived from the plugin I wrote to put AdSense on my blog.

    Try to activate the plugin in the control panel and see if that works for you.

    Coyote: I don’t want the ads in the sidebar, like you. I want them to appear in the main section where the content is. If I just put the adsense code into the index, the ads would show up after every post I make.

    unteins: Okay, so I’ve taken out whatever I put in the index – I misunderstood that bit. I’ve uploaded the plugin, renamed it to to php and not phps, CHMODed it to 666, made sure it’s activated in in the plugins section of the control panel… but still I see nothing on my blog.

    Am I supposed to do something in the templates section of the control panel? I can see the file and edit – I currently have $candy[4] = 'The awesome 4th post of the page!'; so I should be seeing something on my fourth post, right?

    I’m using WP 1.2.2 and version 1.2.0 of the plugin. Is that the problem?

    You can do it in the main section, by hand, really easy, with ‘full control’. Was previously discussed here:

    The basic info in case you don’t want to try and follow the thread, I’ll repeat here:

    For new WP1.5 themes, you want to look for:

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

    For more granular control, you can instead implement this stuff by-hand via the following.

    Just before the if (have_posts()) line add:

    <?php $max_post_num = $wp_query->post_count; $cur_post_num = 0; ?>

    Just after the if (have_posts()) line add:

    <?php $cur_post_num++; ?>

    Then, before the end of the posts loop, which in new themes is:

    <?php endwhile; else: ?>

    You insert a test like:

    if ($cur_post_num==2) // show something after second post on a page
    { ... }

    Note that with current themes, you’ll want to ‘strategically’ pick where you place your test+insert code. I prefer to place it inside the “post” DIV, after the “feedback” DIV. That’s just me. 😉


    The download link for this plugin ( seems to be down. Does anyone know of a mirror or a good alternative?

    could someone edit this index.php file for a google ad after the first post?

    this will make it alot easier for people to just change the google id

    or say cut what you are looking for above and paste the new code in its place whith a google ad in it this whill make it alot easier at this has come up alot!

    Mark (podz)


    Support Maven

    Moosecandy is here:

    pedmic – this is your second post about adsense. Did you read the answer to your first post ?

    I can find

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

    but I dont understand where to edit it

    would it be like this

    <?php $max_post_num = $wp_query->post_count; $cur_post_num = 0; ?><?php if (have_posts()) : while (have_posts()) : the_post(); ?><?php $cur_post_num++; ?>


    if ($cur_post_num==2) // show something after second post on a page{ … }<?php endwhile; else: ?>

    where do i put my google ad? do I replace “show something after second post on a page” with the google ad code?



    My sample above is outdated, and replaced by my CG-Inbetween plugin (available with my other WordPress contest entries…). It will allow you to store your google adsense code in its own html file (so you can edit it easily), and then ‘include’ it in your page between posts (say, after post #1). Pretty easy. You can also ‘insert’ text, or a single/simple php function call, as well as a file insertion, at a given page offset. And you can have as many inbetweens active as you want (i.e., have them after post 1, 4, and after the last post on the page, for example…).


    Moosecandy doesn’t work at all and I can’t insert the AdSense code, because it is code.

    CG-Inbetween works well for AdSense if you place the adsense in a named file (or multiple named files, if you vary styles, etc.), and create an Inbetween that includes the file at the desired offset. Ping me on my website if you need help with this…


    Just quickly scanning posts so I apologise if this has been responded to above.

    I’ve just added Adsense to to both the main sidebar (sidebar.php) and individual (page.php) posts rather than the main template (index.php) as I didn’t want them showing up on the main page (I’m referring to the kubrick template but I’m sure this can easily be adapted to templates you use).

    Used in conjunction with keywords (I use jerome’s or)I’ve been able to get relevant ads showing up in the majority of my posts. I haven’t looked at adding anything to monthly or category outputs yet.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Moosecandy / Adsense’ is closed to new replies.