Hi I want to place an image at the fifth position while displaying the articles in home page. Say I have set the posts to display 14 in home page and the fifth and tenth position the same image has to be placed in between the posts. Below is the code I am modifying it.

<?php if( ( $wp_query->current_post + 1) % 2 == 0 ) { echo '</div><div class="post-row"><article id="post-777" class="group grid-item post-777 post type-post status-publish format-standard has-post-thumbnail hentry category-health-media">
<div class="post-inner post-hover">

    <div class="post-thumbnail"><img width="520" height="245" 
    src="http://xyz.in/wp-
    content/uploads/2017/05/shutterstock_137498780-520x245.jpg" 
    class="attachment-thumb-medium size-thumb-medium wp-post-image" alt="" 
    srcset="http://xyz.in/wp-
    content/uploads/2017/05/shutterstock_137498780-520x245.jpg 520w, 
    http://healthpick.in/wp-content/uploads/2017/05/shutterstock_137498780-
    720x340.jpg 720w" sizes="(max-width: 520px) 100vw, 520px"></div></div>
    </article>'; }; endwhile; echo '</div>'; ?>
    </div><!--/.post-list-->
  <?php endif; ?>

Can you suggest where I am going wrong. Please help me.

Read more here: Images to be placed after three posts


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: