• i want to show ads in between the front page articles means hueman theme shows 10 article on front page but i want and add in between any of that page ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi Aprazors. Are you using the default home page layout of two columns of posts, or the Standard Blog layout of posts in a single column? When you say “in between any”, where specifically do you want to place the ads?

    Thread Starter Aprazors

    (@aprazors)

    after 5 or 6 post in front page !

    If you’re using the default home page layout, give this a try:
    1. Create a new sidebar in Theme Options > Sidebars; give it a unique id like “sidebar-ads” or whatever you like.
    2. In Widgets, add a text widget to the sidebar, then place your ad code in the widget.
    3. Copy index.php from the parent theme to your child theme.
    4. In your child theme index.php file, find the following code block:

    <div class="post-list group">
    	<?php $i = 1; echo '<div class="post-row">'; while ( have_posts() ): the_post(); ?>
    		<?php get_template_part('content'); ?>
    	<?php if($i % 2 == 0) { echo '</div><div class="post-row">'; } $i++; endwhile; echo '</div>'; ?>
    </div><!--/.post-list-->

    5. Replace that block of code with this:

    <div class="post-list group">
    
    <?php $i = 1;								// initialize the post counter
    echo '<div class="post-row">';				// create the post-row div
    while ( have_posts() ): the_post(); ?>		<!-- while we have posts -->
    	<?php get_template_part('content'); ?>		<!-- display the post -->
    
    	<?php if ($i % 2 == 0) {				// if we've shown 2 posts
    		echo '</div>';						// close this post-row div
    
    		// BEGIN insert my custom widget after 6 posts
    		if ($i % 6== 0) {					// if we've displayed 6 posts
    			echo '<div class="my-ad-widget">';		// create the widget div
    			dynamic_sidebar('sidebar-ads');		// show the widget
    			echo '</div>'; 				 	// close the widget div
    		}
    		// END insert my custom widget
    
        echo '<div class="post-row">';			// create the next post-row div
    	}
    
    	$i++;									// increment the post counter
    endwhile;
    echo '</div>';								// close the trailing post-row div
    ?>
    
    </div><!--/.post-list-->

    6. Add the following css to position the sidebar:

    .my-ad-widget {
      float:left;
    }

    Let me know if you have any questions.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to show adsence ads in front page articles?’ is closed to new replies.