• Hey everyone, I thought there was a plugin for this, but I could be wrong.

    I am looking for a plugin that will allow me to add an advertisement between the first and second post on my blog.

    Anyone heard of this?

Viewing 15 replies - 1 through 15 (of 23 total)
  • Search for Moosecandy ?
    I think thats the one you may need.

    Thread Starter phoenixd

    (@phoenixd)

    Trying:
    https://jason.goldsmith.us/wp-plugins/moosecandy.phps

    But it is not doing anything.

    I am using WP 1.5

    The div that it is supposed to create is not even showing up.
    Plugin is uploaded, and activated.
    I just used Hello as the test text.

    Thread Starter phoenixd

    (@phoenixd)

    I am using a modified Mallow template (which is based off Kubrick.)

    Does the code work with 1.5? And is there anyway to make it work with a Kubrick based template?

    Thread Starter phoenixd

    (@phoenixd)

    Okay, I figured it out.

    I had to change a few things.

    $candy[3] = Hello’;

    // Don’t change anything below this line
    $dropping = 1;

    function moosecandy($text)
    {
    global $dropping, $candy;
    if (isset($candy[$dropping]))
    {
    $the_content = “<div id=\”moosecandy$dropping\” class=\”moosecandy\”>”;
    $the_content .= $candy[$dropping];
    $the_content .= ‘</div>’;

    $dropping++;
    $text = $text . “\n” . $the_content;
    }
    else { $dropping++;}
    return $text;
    }

    add_filter(‘the_content’, ‘moosecandy’);
    ?>

    Thread Starter phoenixd

    (@phoenixd)

    Now it shows Hello after my 3rd post. ??

    Here’s a solution

    1) Open your index.php file. Look for some code similar to this:
    <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
    This is the start of the WP-Loop.
    2) Just BEFORE that line, insert this code:
    <?php $showAdSense = True; ?>
    3) find this code:
    <?php endforeach; else: ?>
    This is the bottom of the loop.
    4) Just BEFORE that line, put this:
    < If ($showAdSense) { ?> ... stick the adsense code here ... <?php $showAdSense = False;} ?>
    Making the appropriate changes (ie, inserting the adsense code where noted.
    5) Save file.
    6) Sit back and enjoy.

    Cudos to techgnome who posted this quite a while ago. Hope this works,

    PS. I don’t like the wordpress search feature, took me a whole bunch of different combinations of keywords to try and find this old post.

    That’s also instructions for old theme styling. for new 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. ??

    -d

    ok nice, but how do i put the js-script for adsense in the php-file…
    me and php ??
    here is the indexfile

    —CODE—

    <?php get_header(); ?> <div id=”content” class=”narrowcolumn”> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div class=”post”> <h2 id=”post-<?php the_ID(); ?>”>” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><?php the_title(); ?></h2> <small><?php the_time(‘F jS, Y’) ?> <!– by <?php the_author() ?> –></small> <div class=”entry”> <?php the_content(‘L???¤s forts???¤ttningen »’); ?> </div> <p class=”postmetadata”> <br> Arkiverat i kategorin <?php the_category(‘, ‘) ?> | <?php comments_popup_link(‘Hela artikeln »’, ‘1 Kommentar »’, ‘% Har kommenterat artikeln »’); ?> <!– <?php edit_post_link(‘??a€?ndra i inl???¤gget’,”,’|‘); ?> –> <!– <?php trackback_rdf(); ?> –> </div> <?php endwhile; ?> <div class=”navigation”> <div class=”alignleft”><?php posts_nav_link(”,”,’« Previous Entries’) ?></div> <div class=”alignright”><?php posts_nav_link(”,’Next Entries »’,”) ?></div> </div> <?php else : ?> <h2 class=”center”>Not Found</h2> <p class=”center”><?php _e(“Sorry, but you are looking for something that isn’t here.”); ?> <?php include (TEMPLATEPATH . “/searchform.php”); ?> <?php endif; ?> </div> <?php get_sidebar(); ?> <?php get_footer(); ?>

    —CODE—

    were to put the google adsensecode (javascript) and i should use some more code to get it right or?

    regards

    hmm its the https://www.top-10-list.com/ site i am talking about…
    mainpage in defaulttemplate WP 1.5.

    the part where I said:

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

    You could do:

    <?php if ($cur_post_num==1) { /* between 1st and 2nd */ ?>
    ... add your raw google adsense stuff here ...
    <?php } ?>

    Or alternately, put your adsense into a file like “adsense1.htm”, and just include it:

    <?php if ($cur_post_num==1) include("adsense1.htm"); ?>

    Note you might need to do a more detailed path to the included file, there’s some tag that gets the theme path or the blog path on the server, and you might want to use that.

    -d

    thanx david.
    i liked the ilncludeversion…
    have this call to the file in templates indexfile:
    ————————————————-
    <?php get_header(); ?> <div id=”content” class=”narrowcolumn”> <?php if ($cur_post_num==1) include(“https://www.top-10-list.com/wp-content/themes/default/adsense1.htm&#8221;); ?>
    ————————————————-

    my site is https://www.top-10-list.com/
    and WP is in root

    this is my adsense1.htm-file:
    ——————————–
    <html><head><title></title></head>
    <body>
    <script type=”text/javascript”><!–
    google_ad_client = “pub-9702519331186124”;
    google_ad_width = 728;
    google_ad_height = 90;
    google_ad_format = “728x90_as”;
    google_ad_channel =””;
    google_color_border = “FFFFFF”;
    google_color_bg = “FFFFFF”;
    google_color_link = “0000FF”;
    google_color_url = “008000”;
    google_color_text = “FF9933”;
    //–></script>
    <script type=”text/javascript”
    src=”https://pagead2.googlesyndication.com/pagead/show_ads.js”&gt;
    </script>
    </body>
    </html>
    ——————
    or here https://www.top-10-list.com/wp-content/themes/default/adsense1.htm

    the adsensecode doesnt show up, could it take some time or if i dont see it is it an error you think??

    many thanx

    hmm when opening the adsense1.htm-file alone it works!
    but putting URL https://www.top-10-list.com/wp-content/themes/default/adsense1.htm
    in browser doesnt ;(
    cant think of the URL as wrong…

    The URL isn’t wrong…. the HTML in the adsense.html file is…. remove _EVERYTHING_ before the opening script tag….. and everything AFTER the last closing script tag….

    There’s no need to have a head or the html tags…. WP will have already out put those.

    Tg

    yeah, JUST the script code that Adsense generated for you.

    Also, you can’t (really) do an ‘include’ on a http: URL. if it is within your theme folder already, you should just be able to do:
    include(“adsense1.htm”);
    … as it’s in the same folder as the file including it.

    -d

    THANK YOU so much for the code to slip advertising into posts. We were looking for this everywhere, wondering how others were able to do it. And it works just fine in 1.5

    -Gothiphop
    https://www.gothiphop.com

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘Add Ad between First and Second Post’ is closed to new replies.