This question already has an answer here: loop 1: image + contents and image + content loop 2: content + image and content + image in wordpress how can i display my post according this [closed] (1 answer) Closed 5 years ago.admin管理员组文章数量:1415136
I have two rows to display posts in first row i have two posts image + content , image + content And in second row the post layout change means content + image , content + image can you solve this my problem this is my code :
<div class="main_blog_content">
<?php $arr = array(
'posts_per_page' => 4
);?>
<?php
$arrg_query = new WP_Query($arr);
if(have_posts() ) : while($arrg_query ->have_posts() ) : $arrg_query ->the_post();
foreach ($arr as $i):
$i++;
// one layout type
if($i%2 == 0):
?>
<div class="col-sm-6">
<div class="single_blog_area textwhite">
<div class="row">
<div class="col-sm-6 no-padding">
<div class="single_blog_img">
<?php the_post_thumbnail(); ?>
<!--<img src="<?php //echo get_bloginfo('template_url');?>/assets/images/blog1.jpg" alt="" />-->
</div>
</div>
<div class="col-sm-6 no-padding">
<div class="single_blog_text s_b_left">
<p>
<a href="<?php the_permalink();?>">
<?php the_category( ' ' ); ?></a>
</p> <h3>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?></a></h3>
<div class="separator2">
</div>
<?php $content = get_the_content(); ?>
<p>
<?php echo wp_trim_words($content, 43); ?>
</p>
<a href="<?php the_permalink(); ?>" class="read_more">Read More >></a>
</div>
</div>
</div>
</div>
</div>
<?php
// another layout type
else:?>
<div class="col-sm-6">
<div class="single_blog_area textwhite">
<div class="row">
<div class="col-sm-6 col-sm-push-6 no-padding">
<div class="single_blog_img">
<?php the_post_thumbnail(); ?>
<!--<img src="assets/images/blog3.jpg" alt="" />-->
</div>
</div>
<div class="col-sm-6 col-sm-pull-6 no-padding">
<div class="single_blog_text s_b_right">
<p>
<a href="<?php the_permalink();?>">
<?php the_category( ' ' ); ?></a>
</p>
<h3>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?></a>
</h3>
<div class="separator2">
</div>
<?php $content = get_the_content(); ?>
<p>
<?php echo wp_trim_words($content, 43); ?>
</p>
<a href="<?php the_permalink();?>" class="read_more">Read More >></a>
</div>
</div>
</div>
</div>
</div>
<?php endif;?>
<?php endforeach; ?>
<?php endwhile; endif; ?>
</div>
i send a image of posts that i want :
本文标签: loopDiffrent layout for posts
版权声明:本文标题:loop - Diffrent layout for posts 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745227002a2648653.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论