WordPress.org

Support

Support » Themes and Templates » Adding ads between posts on the homepage

Adding ads between posts on the homepage

Viewing 2 replies - 1 through 2 (of 2 total)
  • There are several ad plugins that allow you to do things like this. Have you looked into them? This is one I like to use: http://wordpress.org/plugins/adrotate/, but there are several others that also allow ads to be placed within posts.

    Otherwise you will have to modify the php code for your homepage.

    I just changed index.php and added some code. Here it is if anyone cares.

    <?php if ( have_posts() ) : ?>
    
    <?php $count = 1; ?>
    
    	<?php while ( have_posts() ) : the_post(); ?>
    
    		<?php get_template_part( 'content', ( post_type_supports( get_post_type(), 'post-formats' ) ? get_post_format() : get_post_type() ) ); ?>
    
    		<?php if ( is_singular() ) comments_template(); // Loads the comments.php template. ?>
    
    		<?php if($count == 1):?>
    
                <div class="ad-homepage">
    		  // Ad code goes here
                </div>
    
            <?php endif;?>
    
    	<?php $count++;?>
    
    	<?php endwhile; ?>
    
    <?php else : ?>
    
    	<?php get_template_part( 'loop-error' ); // Loads the loop-error.php template. ?>
    
    <?php endif; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding ads between posts on the homepage’ is closed to new replies.