三个帖子之后放置的图片

时间:2017-05-11 10:46:38

标签: php wordpress

您好我想在主页上显示文章时将图像放在第五个位置。假设我已将帖子设置为在主页中显示14,并且第五和第十位置必须在帖子之间放置相同的图像。下面是我修改它的代码。

<?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; ?>
你能告诉我哪里出错吗?请帮帮我。

1 个答案:

答案 0 :(得分:1)

如果你想在第5或第10个位置后放置图像,只需更改逻辑

if( ($wp_query->current_post) % 5 == 0 )