Hi how can I display the adsense directly above the content after click on "Read More" in index template? e.g. in antiaging911.com I would like to configure it in template level and not post level. Can it be done? Thanks.
I'm working on something, but it's still not doing what I want it to do completely - though it might work for you. It's for my wordpress blog; I'm a perl coder but I hacked this together after a lot of messing around. I use this in the index.php file right after the php get header code: <?php $AC_Onlyshow = $_SERVER['REQUEST_URI']; $ADSENSE_CODE = <<<ADSENSECODE <div style="display:block;float:left;padding:5px;"> <script type="text/javascript"><!-- google_ad_client = "pub-XXXXXXXXXXXXXXX"; google_ad_width = 250; google_ad_height = 250; google_ad_format = "250x250_as"; google_ad_type = "text"; //2007-03-31: seowps - single pages top google_ad_channel = "5756494487"; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "7DA721"; google_color_text = "000000"; google_color_url = "000000"; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div> ADSENSECODE; ?> Code (markup): Later on down the page, I use this. It might be slightly different for you, but I'll post the surrounding code so it'll be easier for you to find the right location: <?php get_sidebar(); ?> <hr /> <div id="content"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php // Post dates off by default the_date('','<h2>','</h2>'); ?> <h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2> <div class="meta"><?php _e("Posted in"); ?> <?php the_category(',') ?> by <?php the_author() ?> on the <?php the_time('F jS, Y') ?> <?php edit_post_link(__('Edit This')); ?></div> <div class="main"> [color="red"] <?php if ( $AC_Onlyshow != '/' && (!preg_match("/\/index.php+?/","$AC_Onlyshow"))) { echo "$ADSENSE_CODE"; } ?> [/color] <?php the_content(__('(more...)')); ?> Code (markup): The part in red is the code to put in place. What it does is it'll show adsense code on pages other than the main page (provided your blog is installed in the main directory, and the code won't show on search pages. I just 3 minutes ago, literally, realized that the adsense code shows up on archive & category pages. . . but I'll see what I can do with that over time. Be sure to backup your files before making any changes - and use this if it works for you. . . It took me a good deal of time to figure this out cuz I know nothing about php. . .and it's still not right for my purpose, though it might work for you.
ednit, i try out the code just now but the adsense did not display under the "read more" marks..but under the post title.. here's how's the code look like in the template.. <div id="contentleft"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1> <div style="display:none"><p>Posted on <?php the_time('F j, Y'); ?><br />Filed Under <?php the_category(', ') ?> | <?php comments_popup_link('Leave a Comment', '1 Comment', '% Comments'); ?></p> </div> <?php if ( $AC_Onlyshow != '/' && (!preg_match("/\/index.php+?/","$AC_Onlyshow"))) { echo "$ADSENSE_CODE"; } ?> <?php the_content("...Continue Reading on " . get_the_title('', '', false) . "»»") ; ?><div style="clear:both;"></div> Code (markup): Does the adsense display right under the paragraph that you mark read more in your blog index template?