1
我试图根据创建帖子的时间在我的博客帖子页面上创建不同的布局。因此博客文章1将有一个类,而文章2将有另一个类,而文章3将有一个最终的类。很难解释,但这里是我的代码,希望它会更有意义:Blog post layouts wordpress
<?php
if(have_posts()):
while(have_posts()): the_post();
$counter = 1;
?>
<?php if($counter == 1){ ?>
<div class="new-row">
<div class="boxes picture-box contact-smaller-box">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
</div><!--/.picture box-->
<div class="boxes white-box contact-smaller-box">
<div class="box-inner right-side">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p><?php echo substr(get_the_excerpt(), 0,70); ?></p>
<a href="<?php the_permalink(); ?>" title="find out more" class="find-out pink-link">Read More</a>
</div><!--/.box inner-->
<div class="arrow arrow-left"><img src="..."></div>
</div><!--/.white box-->
</div><!--/.new row-->
<?php $counter = $counter++; ?>
<?php } if($counter == 2){?>
<!-- second section of the blog post content -->
<div class="new-row">
<div class="boxes pink-box contact-smaller-box">
<div class="box-inner">
<h2><?php the_title(); ?></h2>
<p><?php echo substr(get_the_excerpt(), 0,70); ?></p>
<a href="<?php the_permalink(); ?>" title="find out more" class="find-out purple-link">Read More</a>
</div><!--/.box inner-->
<div class="arrow arrow-right"><img src="..."></div>
</div><!--/.pink box-->
<div class="boxes picture-box contact-smaller-box">
<img src="..." alt="hearing aids for adults">
</div><!--/.picture box-->
</div><!--/.new row-->
<?php } ?>
<?php
endwhile;
endif;
?>
在我的两个测试柱都表示作为第一类职位的时刻,所以即时通讯思想我的柜台工作不正常,或我有我的div在错误的位置做这项工作。即时通讯新的工作与PHP,所以我不知道我要去哪里错了。任何建议都会很棒。