Coryan Posted December 25, 2007 Share Posted December 25, 2007 I am using WordPress with a custom theme to write a blog. I just set it up and added Google Adsense advertising to appear at the end of my posts. However, I only want the ads to appear at the end of the first post. How do I change the code so that the ads do not repeat on each post? Here is the relevant section of code: <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <div class="date"><span><?php the_time('M') ?></span> <?php the_time('d') ?></div> <div class="title"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2><p class="submeta">By <strong><?php the_author(); ?></strong> <div class="postdata"><span class="category"><?php the_category(', ') ?></span> <span class="comments"><?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></span></div> </div> <div class="entry"> <?php the_content('Continue reading »'); ?> <?php adsensem_ad('midpost468x60'); ?> <?php if(function_exists(�the_tags�)) the_tags('\\\\ tags: ', ', ', '<br />'); ?> </p> </div><!--/entry --> </div><!--/post --> <?php endwhile; ?> I have never used php, but I follow instructions well. The adsense code <?php adsensem_ad('midpost468x60'); ?> was provided by a plugin. Again, the ads are appearing without a problem, but I need to limit them to only the first ad. You can see the page at www.uturnahead.com. Thank you in advance for any assistance you can offer. Link to comment https://forums.phpfreaks.com/topic/83130-need-help-stopping-code-from-repeating/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.