+ Reply to Thread
Results 1 to 22 of 22

Thread: Adding Banners after posts in WP

  1. #1
    Moonshine washing line Angel's Avatar
    Join Date
    Sep 2003
    Hood
    Right Here
    Posts
    31,102

    Adding Banners after posts in WP

    NY Jester had asked about my blog Bountiful Babes and how I got banners to show up in the posts so I thought i'd create a new post so everyone can find out if they're interested.

    The way I have those banners show up is that they're "hard coded" if you will, on to my wordpress templates so the same banners will show up on every page, because of this I pick my 7 favorite sponsors (since I have 7 posts showing on each page) and save a banner for each one that I feel my surfers would be attracted to. Now my banners don't get as much traffic as my blog posts/pictures but they still get me traffic so I make use of the space. Now I have the banners I want to use after the posts I go in to my wordpress templates.

    This "coding" will work for any wordpress template and is also useful in mainstream blogs as well (I'll give an example later if you're interested). Now for the code, you want to open your index.php template page from your wordpress backend.

    Find where it says
    <?php while (have_posts()) : the_post(); ?>

    replace that line with
    <?php while (have_posts()) : the_post(); $loopcounter++; ?>

    This enables a "counter" so you can "count" posts on the page, ie: post 1,2,3,4,5,6,7 (since I have 7 posts per page)

    Now that you've numbered the posts you want to tell your blog what to post after each post and where.

    Find the section of your index.php where you want the banner to show, in the example of Bountiful babes I went to the end of the post code:

    <div class="storycontent">
    <?php the_content(__('(more...)')); ?>
    </div>
    <?php
    else:
    echo "";
    endif; ?>


    (This code is going to be different for each template, this is simply how it's laid out on my template) and then right after that section of code I place this code:

    <?php if ($loopcounter == 1) { ?>

    <div class=“adsense”><b><center><a href="LINK1"><img src="BANNER1"></a></center></b><br></div>
    <?php } ?>

    <?php if ($loopcounter == 2) { ?>

    <div class=“adsense”><b><center><a href="LINK2"><img src="BANNER2"></a></center><br></b></div>
    <?php } ?>

    <?php if ($loopcounter == 3) { ?>

    <div class=“adsense”><b><center><a href="LINK3"><img src="BANNER3"></a></center><br></b></div>
    <?php } ?>


    <?php if ($loopcounter == 4) { ?>

    <div class=“adsense”><b><center><a href="LINK4"><img src="BANNER4"></a></center></b><br></div>
    <?php } ?>


    <?php if ($loopcounter == 5) { ?>

    <div class=“adsense”><b><center><a href="LINK5"><img src="BANNER5"></a></center></b><br></div>
    <?php } ?>


    <?php if ($loopcounter == 6) { ?>

    <div class=“adsense”><b><center><a href="LINK6"><img src="BANNER6"></a></center></b><br></div>
    <?php } ?>

    <?php if ($loopcounter == 7) { ?>

    <div class=“adsense”><b><center><a href="LINK7"><img src="BANNER7"></a></center></b><br></div>
    <?php } ?>


    This code tells your blog what image to pull from where and what to link it to (just make sure you replace the LINK and BANNER sections of code above with the right links!). For those concerned about not having an "adsense" category not coded in to your css sheet it should pull up just fine anyway but if you'd prefer you can add one yourself.

    Now you should be getting banners pulling up after each of your posts, just change the <center> alignment to left/right if you'd prefer different alignment of your banners.

    I mentioned mainstream blogs above as well which brings to mind one of my mainstream blogs that I wanted to display google adsense after every other post instead of every post. You can do this with the same process above but instead of the second section reading as so:

    <?php if ($loopcounter == 1) { ?>

    <div class=“adsense”><b><center><a href="LINK1"><img src="BANNER1"></a></center></b><br></div>
    <?php } ?>
    ...


    You want to place this code instead:

    <?php if ($loopcounter % 2 == 0) { ?>

    <div class=“adsense”>ADSENSE SCRIPT GOES HERE</div>

    <?php } ?>


    This tells the counter to only place google ads after every second post, this is especially helpful when you have more than three posts per page since Adsense has restrictions on how many ads you can show per page and it gives a more uniform look to your ad spots on your blog. If you want every 3 posts change the 2 above to a 3 and so on.


    Hope that helps some of you placing ads on your blogs

    FEEDS by RSSBUILDERS!
    My Cock Blog

  2. #2
    aka smutguy
    Join Date
    Oct 2006
    Hood
    here and there
    Posts
    1,710
    Pimp $
    589
    very nice article

    i will try to set that up this weekend

  3. #3
    VP of blather &amp; bullshit born2blog's Avatar
    Join Date
    Sep 2006
    Hood
    Googleville
    Posts
    7,798
    Pimp $
    535
    Interesting approach, I'll have to try it on a couple of blogs. I've put banners in blog posts like that before but not with a random banner generating script like that, I've always just used banners directly related to the posts, but mixing it up like this sounds like a good technique too.



    Juicy Ads - Buy & Sell Quality Traffic!!

  4. #4
    Moonshine washing line Angel's Avatar
    Join Date
    Sep 2003
    Hood
    Right Here
    Posts
    31,102
    This isn't a random generating script, it simply pulls a set banner under a set post, for example post one on a page will always show banner 1 underneath it. If you want to rotate random banners you could try plugging in the adrotator plugin echo code instead of the static banner code; however, you're going to need to create (in this example) 7 different txt files of banners unless you just want to chance pulling up the same banner multiple times and pull from one txt file.

    FEEDS by RSSBUILDERS!
    My Cock Blog

  5. #5
    Sofa King Band NY Jester's Avatar
    Join Date
    Oct 2007
    Hood
    Just where I am
    Posts
    6,934
    Pimp $
    415
    Thanks Angel for that explaination, Im sure everyone will find that useful.
    Jester-X - Webmaster Services
    Maximize Your Niche Traffic - Fetish Wealth
    Work Smarter With Nifty Stats
    *ICQ 147-079-406*

  6. #6
    Keith Moon's Baby drunken's Avatar
    Join Date
    Jan 2005
    Hood
    videomilfs.net
    Posts
    558
    Pimp $
    395
    great post angel I have bookmarked this thread.

    can you tell me who designed your blog?
    looking for mature/MILF mgp trades. icq 15655034

  7. #7
    I eat kittens Wiggles's Avatar
    Join Date
    Mar 2005
    Posts
    28,184
    Pimp $
    5,202
    would be easier to install one of the plugins

    MAKE MAD $$$ ON THE HOTTEST TRANNY SOLO GIRLS AND TRANNY SITES ON THE NET!

    TRADE HARDLINKS HERE! - Currently need cheating wife/cuckold, blowjob/facial and Tranny trades

  8. #8
    Moonshine washing line Angel's Avatar
    Join Date
    Sep 2003
    Hood
    Right Here
    Posts
    31,102
    Quote Originally Posted by drunken View Post
    great post angel I have bookmarked this thread.

    can you tell me who designed your blog?
    I did, well I took a generic theme and tweaked it to look the way I wanted it to

    Wiggles, what plugins did you have in mind?

    FEEDS by RSSBUILDERS!
    My Cock Blog

  9. #9
    Pimpin' Angel A.J. Angel's Avatar
    Join Date
    Jul 2007
    Hood
    Paris, France
    Posts
    9,078
    Pimp $
    -4
    Bumpity bump! I need help! Angel? Anyone?

    I've just added the code, it seems to be working fine and all... but... instead of being after a post, it seems that I've put it before a post.

    Not sure why and how come and I have no clue what to do or where to put the code. As of now, there's a huge gap between the post and the banner. What I mean is this: Bumble Angelz! Not good!

    I can edit the CSS to size down part of the gap due to the height and margin-bottom characteristics of the postspace but then, each post is too close to one and another. Not good either!

    Here's the index file coding with in red, the additional codes:

    <?php get_header(); ?>

    <!--include sidebar-->
    <?php include(TEMPLATEPATH."/l_sidebar.php");?>
    <!--include sidebar-->
    <?php include(TEMPLATEPATH."/r_sidebar.php");?>
    <div id="content">
    <!--index.php-->
    <!--the loop-->
    <?php if (have_posts()) : ?>
    <!--the loop-->
    <?php while (have_posts()) : the_post(); $loopcounter++; ?>

    <!--post title as a link-->
    <h1 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>
    <p><b>By <?php the_author(); ?></b> | <?php the_time('F j, Y'); ?> </p>
    <div class="postspace2">
    </div>
    <!--post text with the read more link-->
    <?php the_content('Read the rest of this entry &raquo;'); ?>
    <!--show categories, edit link ,comments-->

    <p><b>Topics:</b> <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    <div class="postspace">
    </div>
    <!--end of one post-->

    <?php if ($loopcounter == 1) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>

    <?php if ($loopcounter == 2) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>

    <?php if ($loopcounter == 3) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>


    <?php if ($loopcounter == 4) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>


    <?php if ($loopcounter == 5) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>


    <?php if ($loopcounter == 6) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>

    <?php if ($loopcounter == 7) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>

    <?php if ($loopcounter == 8) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>


    <?php if ($loopcounter == 9) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>

    <?php if ($loopcounter == 10) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>


    <?php endwhile; ?>

    <!--navigation-->
    <?php next_posts_link('&laquo; Previous Entries') ?>
    <?php previous_posts_link('Next Entries &raquo;') ?>

    <!--do not delete-->
    <?php else : ?>

    Not Found
    Sorry, but you are looking for something that isn't here.
    <?php include (TEMPLATEPATH . "/searchform.php"); ?>
    <!--do not delete-->
    <?php endif; ?>

    <!--index.php end-->
    </div>


    <!--include footer-->
    <?php get_footer(); ?>
    "Reality is wrong. Dreams are for real." Tupac Amaru Shakur (June 16th, 1971 - September 13th, 1996)

    Exquisite Angelz | Webmasters
    http://www.exquisiteangelz.com/
    E-Mail | Yahoo! | Windows Live | Icq | AIM

  10. #10
    How much does these points get me? Vixxen's Avatar
    Join Date
    Jan 2005
    Hood
    Tha Durty South!
    Posts
    880
    Pimp $
    197
    good stuff thanks for sharing.

    hey off topic, isnt your avatar custom made? I'm sure I saw it being used else where.

  11. #11
    Who said pimpin ain't easy? kaz's Avatar
    Join Date
    Sep 2007
    Posts
    9,542
    Pimp $
    721
    Angel, you are definitely the php queen Nicely done!

  12. #12
    Moonshine washing line Angel's Avatar
    Join Date
    Sep 2003
    Hood
    Right Here
    Posts
    31,102
    <?php get_header(); ?>

    <!--include sidebar-->
    <?php include(TEMPLATEPATH."/l_sidebar.php");?>
    <!--include sidebar-->
    <?php include(TEMPLATEPATH."/r_sidebar.php");?>
    <div id="content">
    <!--index.php-->
    <!--the loop-->
    <?php if (have_posts()) : ?>
    <!--the loop-->
    <?php while (have_posts()) : the_post(); $loopcounter++; ?>

    <!--post title as a link-->
    <h1 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>
    <p><b>By <?php the_author(); ?></b> | <?php the_time('F j, Y'); ?> </p>
    <div class="postspace2">
    </div>
    <!--post text with the read more link-->
    <?php the_content('Read the rest of this entry &raquo;'); ?>
    <!--show categories, edit link ,comments-->

    <p><b>Topics:</b> <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    <div class="postspace">
    <?php if ($loopcounter == 1) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>

    <?php if ($loopcounter == 2) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>

    <?php if ($loopcounter == 3) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>


    <?php if ($loopcounter == 4) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>


    <?php if ($loopcounter == 5) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>


    <?php if ($loopcounter == 6) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>

    <?php if ($loopcounter == 7) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>

    <?php if ($loopcounter == 8) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>


    <?php if ($loopcounter == 9) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>

    <?php if ($loopcounter == 10) { ?>
    <div><b><center><a href="http://www.macandbumble.com/?ref=206523"><img src="/images/macandbumble_468x60.gif" width="468" height="60" border="0"></a></center></b></div>
    <?php } ?>

    <?php endwhile; ?>

    </div>
    <!--end of one post-->



    <!--navigation-->
    <?php next_posts_link('&laquo; Previous Entries') ?>
    <?php previous_posts_link('Next Entries &raquo;') ?>

    <!--do not delete-->
    <?php else : ?>

    Not Found
    Sorry, but you are looking for something that isn't here.
    <?php include (TEMPLATEPATH . "/searchform.php"); ?>
    <!--do not delete-->
    <?php endif; ?>

    <!--index.php end-->
    </div>


    <!--include footer-->
    <?php get_footer(); ?>





    Give that a try

    FEEDS by RSSBUILDERS!
    My Cock Blog

  13. #13
    Moonshine washing line Angel's Avatar
    Join Date
    Sep 2003
    Hood
    Right Here
    Posts
    31,102
    Quote Originally Posted by Vixxen View Post
    good stuff thanks for sharing.

    hey off topic, isnt your avatar custom made? I'm sure I saw it being used else where.
    Nope it's not custom made I found it on a free avatar site and snagged it

    FEEDS by RSSBUILDERS!
    My Cock Blog

  14. #14
    Pimpin' Angel A.J. Angel's Avatar
    Join Date
    Jul 2007
    Hood
    Paris, France
    Posts
    9,078
    Pimp $
    -4
    Quote Originally Posted by Angel View Post
    Give that a try
    Seemed to work but then the content column borders are messed up and the footer disappears. That's even worst! Hopefully I backed up the index file!

    "Reality is wrong. Dreams are for real." Tupac Amaru Shakur (June 16th, 1971 - September 13th, 1996)

    Exquisite Angelz | Webmasters
    http://www.exquisiteangelz.com/
    E-Mail | Yahoo! | Windows Live | Icq | AIM

  15. #15
    Moonshine washing line Angel's Avatar
    Join Date
    Sep 2003
    Hood
    Right Here
    Posts
    31,102
    You can try removing the "<?php endwhile; ?>" at the very end of the red code, just a shot in the dark though. If you don't get it fixed with that let me know and i'll grab you on ICQ tomorrow and take a look at it

    FEEDS by RSSBUILDERS!
    My Cock Blog

  16. #16
    VP of blather &amp; bullshit born2blog's Avatar
    Join Date
    Sep 2006
    Hood
    Googleville
    Posts
    7,798
    Pimp $
    535
    off topic but just added a couple link trades with that blog through your trade script Angel



    Juicy Ads - Buy & Sell Quality Traffic!!

  17. #17
    Pimpin' Angel A.J. Angel's Avatar
    Join Date
    Jul 2007
    Hood
    Paris, France
    Posts
    9,078
    Pimp $
    -4
    Quote Originally Posted by Angel View Post
    You can try removing the "<?php endwhile; ?>" at the very end of the red code, just a shot in the dark though. If you don't get it fixed with that let me know and i'll grab you on ICQ tomorrow and take a look at it
    Nevermind, I found another way round to it. I had readd the class property to the banners div tags and to the CSS file, I added a padding-bottom property to the class.

    At the same time, I had given 0px to the height property of the postspace as well as deleting the margin-bottom property. It worked as smooth and neat as I had hoped.

    But that wasn't without your help. Had you not given the code, I wouldn't have been reminded of the class property when reading your code since the PHP code was just under the postspace class in the div tags.

    So... thanks Angel!
    "Reality is wrong. Dreams are for real." Tupac Amaru Shakur (June 16th, 1971 - September 13th, 1996)

    Exquisite Angelz | Webmasters
    http://www.exquisiteangelz.com/
    E-Mail | Yahoo! | Windows Live | Icq | AIM

  18. #18

  19. #19
    Searching for Jimmy Hoffa Mr. Blue's Avatar
    Join Date
    Mar 2005
    Hood
    NY - The Rotten Apple
    Posts
    7,378
    Pimp $
    434
    You can use OpenX and control your advertising across your network...I'm about to set it up next weekend.
    WWSD?
    69Blue.com
    ICQ #223487665

  20. #20
    Pimpin' Angel A.J. Angel's Avatar
    Join Date
    Jul 2007
    Hood
    Paris, France
    Posts
    9,078
    Pimp $
    -4
    Quote Originally Posted by Mr. Blue View Post
    You can use OpenX and control your advertising across your network...I'm about to set it up next weekend.
    I had used OpenX when it was renamed as such. After a few months, I literally dumped it for HTML Rotate from Focal Media. I wasn't using much their stats and it was eating too much resources for the few I use of it.
    "Reality is wrong. Dreams are for real." Tupac Amaru Shakur (June 16th, 1971 - September 13th, 1996)

    Exquisite Angelz | Webmasters
    http://www.exquisiteangelz.com/
    E-Mail | Yahoo! | Windows Live | Icq | AIM

  21. #21
    www.kletoto.com kletoto's Avatar
    Join Date
    Aug 2007
    Hood
    Macedonia,Veles
    Posts
    3,585
    Pimp $
    629
    Looks great Angel , for sure I will try on one of blogs ... thanks for sharing

    Promote with confidence with the best payouts and work with Niche Specific Sites that really Converts !!!

    ICQ : 485 430 791

  22. #22
    RightThoughtRightAction
    Join Date
    Mar 2004
    Hood
    In your PC RAM
    Posts
    1,769
    Pimp $
    303
    http://www.maxblogpress.com/plugins/mba/
    Put banners pretty well where you like
    I got it up and running on 3 blogs within 30 mins
    It also tells you how many times a banner was clicked
    You can also rotate the position of your banners or even rotate the banner themselfs.
    They ask you to joing there email list they keep a link to their site under your banner unless you pay $47 to remove it then you can use it on all your domains.

    It wont hurt your Brain

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts