Adsense in First post in Wordpress

Discussion in 'WordPress' started by Jim bob 9 pants, Nov 19, 2006.

  1. #1
    Hi

    How can I get adsense to show in the first post and only the first post??
     
    Jim bob 9 pants, Nov 19, 2006 IP
  2. Jim bob 9 pants

    Jim bob 9 pants Peon

    Messages:
    890
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I have done it - thanks
     
    Jim bob 9 pants, Nov 19, 2006 IP
  3. pratik

    pratik Notable Member

    Messages:
    2,306
    Likes Received:
    114
    Best Answers:
    0
    Trophy Points:
    200
    #3
    can you please share the trick with us.. i mean how did you do this.. even i use WP and it will prove helpfull...

    thankz in advance
     
    pratik, Nov 19, 2006 IP
  4. Jim bob 9 pants

    Jim bob 9 pants Peon

    Messages:
    890
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ok here goes - this is the index.php in the theme editor. paste the php marked [HERE] in the same place as I have in the WP loop to get the sdsense below the first post only. the blog in question is Angling

    There are only 2 pices of script.

    <?php get_header(); ?>
    
    
    	<div id="content" class="narrowcolumn">
    
    	<?php if (have_posts()) : ?>
    		[HERE]<?php $showAdSense = True; ?>[HERE]
    		<?php while (have_posts()) : the_post(); ?>
    				
    			<div class="post" id="post-<?php the_ID(); ?>">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    				<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    				
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
    				</div>
    		
    				<p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    			</div>
    	[HERE]<?php If ($showAdSense) { ?> <h2>Fishing and Angling</h2><br><script type="text/javascript"><!--
    google_ad_client = "pub-XXXXXXXXXXXXXX";
    google_ad_width = 336;
    google_ad_height = 280;
    google_ad_format = "336x280_as";
    google_ad_type = "text";
    google_ad_channel = "";
    google_color_border = "FFFFFF";
    google_color_bg = "FFFFFF";
    google_color_link = "3D81EE";
    google_color_text = "000000";
    google_color_url = "000000";
    //--></script>
    <script type="text/javascript"
      src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script> <?php $showAdSense = False;} ?>[HERE]
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    		</div>
    		
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		<?php include (TEMPLATEPATH . "/searchform.php"); ?>
    
    	<?php endif; ?>
    <table width="450" height="220" border="1" cellspacing="0" bordercolor="#EEEEEE"><tr bordercolor="#999999" bgcolor="#BFD2C8"><td height="15" colspan="3" nowrap class="largertext"><div align="center"><strong><font color="#004000" size="2" face="Tahoma, Arial">More <a href="http://www.tacklebargains.co.uk/discount_fishing_tackle.htm"><font color="#004000">Discount Fishing Tackle</font></a> Offers from <a href="http://www.tacklebargains.co.uk" target="external"><font color="#004000">Tacklebargains</font></a></font></strong></div></td></tr><tr><td width="33%" height="205"><div align="center"><script src="http://www.tacklebargains.co.uk/randomimage.js"></script><script>SetAffiliate("428767");this.document.write(TextList[NumArray[0]]);</script></div></td><td height="205" width="33%"><div align="center"><script>this.document.write(TextList[NumArray[1]] );</script></div></td><td width="33%" height="205"><div align="center"><script>this.document.write(TextList[NumArray[2]]);</script></div></td></tr></table>
    	</div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
    PHP:
     
    Jim bob 9 pants, Nov 19, 2006 IP
    MarRome likes this.
  5. mStraz

    mStraz Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks Jim bob for the script!

    I was looking for something simple like this, and my PHP skills are non-existent ;)

    Although I changed the H2 hearer to "Sponsored Links" for now because having it as a post heading title like yours (Fishing and Angling) might be against the G-TOS.

    Thanks again!
     
    mStraz, Nov 19, 2006 IP
  6. Bugster

    Bugster Well-Known Member

    Messages:
    98
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    128
    #6
    you can always use a plugin for this - Adsense Deluxe
     
    Bugster, Nov 19, 2006 IP
  7. Jim bob 9 pants

    Jim bob 9 pants Peon

    Messages:
    890
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I will have a look at the plugin. I have tried a couple of adsense plugins and they have been problematic.

    How easy is Adsense delux?

    Jamie
     
    Jim bob 9 pants, Nov 20, 2006 IP
  8. ccano

    ccano Peon

    Messages:
    211
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    ccano, Nov 21, 2006 IP
  9. emthree

    emthree Peon

    Messages:
    187
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    There's a few plugins. I like that though.
     
    emthree, Nov 21, 2006 IP