WordPress的:创建右/左邮政布局
问题描述:
我正在建立一个WP主题,并期待安排我的档案,使布局与每个职位翻转。实质上,将精选图像缩略图显示在一篇文章的左侧,然后在下一篇文章的右侧。WordPress的:创建右/左邮政布局
有没有人有任何想法如何做到这一点? 谢谢
答
WordPress的循环内的帖子计数,使用它甚至奇怪的方式。如果您使用的是WP_Query
实例,那么它将是$var->current_post
。
<?php
while (have_posts()): the_post()
if ($wp_query->current_post % 2 == 0):
?>
Markup for even content
<?php else: ?>
Markup for odd content
<?php
endif;
endwhile;
?>
非常感谢! – JamieMMX
将它标记为正确答案:) – Shubham