Need to add advertising code underneath the first post…
-
I’m just getting a new theme together and I’m having some difficulty. At the moment I have an ad running underneath only the first post on the main page of the blog (www.arseblog.com).
In the new theme I’ve managed to add the code so it appears under the post on a single page but I just can’t figure out how to do it on the main page. It appears under all the posts, not just the first one.
This is the current index page…..
<?php get_header(); ?> <div id="content" class="narrowcolumn"> <?php $postnum = 1; $showadsense1 = 1; ?> <?php if (have_posts()) : ?> <?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> <div id="date-stamp"> <div id="date-text"> <span class="date-bold"><?php the_time('j') ?></span><?php the_time('M') ?><?php the_time('Y') ?> </div> </div> <div class="entry"> <img src="<?php bloginfo('stylesheet_directory'); ?>/images/entry-line.jpg"/><?php the_content('Read the rest of this entry »'); ?> </div> <p class="postmetadata">Posted by <b><?php the_author() ?></b> <!--<?php the_category(', ') ?> --> | <?php edit_post_link('Edit', '', ' | '); ?> - <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> </div> <?php if ($postnum == $showadsense1) { echo ' <b><div align="center"><script language="JavaScript" type="text/javascript" src="https://view.atdmt.com/REP/jview/rswbxo2s2440000001rep/direct/01? click="> </script><noscript><a href="https://clk.atdmt.com/REP/go/rswbxo2s2440000001rep/direct/01/" target="_blank"><img border="0" src="https://view.atdmt.com/REP/view/rswbxo2s2440000001rep/direct/01/" /></a></noscript></div></b> '; } ?> <?php $postnum++; ?> <?php endwhile; ?> <div class="navigation"> <div class="alignleft"> <?php next_posts_link('« Previous Entries') ?> </div> <div class="alignright"> <?php previous_posts_link('Next Entries »') ?> </div> </div> <?php else : ?> <h2 class="center">Not Found</h2> <p class="center">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(); ?>
This is what will be the new home page with the code positioned so it appears under the post, but like I said it appears under every post.
<?php get_header(); ?> <?php $postnum = 1; $showadsense1 = 1; ?> <div id="content"> <?php include(TEMPLATEPATH."/l_sidebar.php");?> <div id="contentmiddle"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="contentdate"> <h3><?php the_time('M'); ?></h3> <h4><?php the_time('j'); ?></h4> </div> <div class="contenttitle"> <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1> Filed Under <?php the_category(', ') ?> </div> <?php the_content(__('Read more'));?><div style="clear:both;"></div> <?php include("postinfo.php"); ?> <b><?php if ($postnum == $showadsense1) { echo ' <div align="center"><script language="JavaScript" type="text/javascript" src="https://view.atdmt.com/REP/jview/rswbxo2s2440000001rep/direct/01? click="> </script><noscript><a href="https://clk.atdmt.com/REP/go/rswbxo2s2440000001rep/direct/01/" target="_blank"><img border="0" src="https://view.atdmt.com/REP/view/rswbxo2s2440000001rep/direct/01/" /></a></noscript></div></b> '; } ?> <!-- <?php trackback_rdf(); ?> --> <?php endwhile; else: ?> <?php _e('Sorry, no posts matched your criteria.'); ?> <?php endif; ?> <?php posts_nav_link(' — ', __('« go back'), __('keep looking »')); ?> </div> <!-- The main column ends --> <?php get_footer(); ?>
If anyone could have a look and let me know how I can restrict the ad appearing to just underneath the first post I’d be very grateful.
- The topic ‘Need to add advertising code underneath the first post…’ is closed to new replies.