Adding ads between posts on the homepage (3 posts)

  1. el terrible bmw
    Posted 2 years ago #

    How would I add adsense in between first and second posts on the homepage?


  2. LauraHartwigDesign
    Posted 2 years ago #

    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.

  3. el terrible bmw
    Posted 2 years ago #

    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
            <?php endif;?>
    	<?php $count++;?>
    	<?php endwhile; ?>
    <?php else : ?>
    	<?php get_template_part( 'loop-error' ); // Loads the loop-error.php template. ?>
    <?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic


No tags yet.