我想做的是创建一个时间表。我想要发生的事情是在每个月的第一个帖子的顶部显示日期。所以它就像一个分隔符,现在知道下面的帖子是在这个月。
目前我只是查询一个类别中的所有帖子。现在我想要发生的是一个 if else 语句。如果它是本月的第一篇文章,请回显一些文本。
<?php $cat=get_field( 'time_taxonomy');?>
<?php global $post; $i=0; $args=array( 'numberposts'=>-1, 'offset'=> 0, 'category' => $cat ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : if ($i==1) { } else {}; setup_postdata($post); $i++; ?>
<div class="ss-container">
<div class="none"><?php echo date("F"); ?></div>
<div class="ss-row">
<div class="ss-left">
<h2 id="month"><?php echo date("F"); ?></h2>
</div>
<div class="ss-right">
<h2><?php echo date("Y"); ?></h2>
</div>
</div>
<div class="ss-row ss-medium">
<!-- Pulling in the featured post imgae and title-->
<?php $image=wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'timeline' ); ?>
<div class="ss-left">
<a href="<?php the_permalink(); ?>" class="ss-circle">
<img class="ss-circle-1" src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>" />
</a>
</div>
<div class="ss-right">
<h3>
<span><?php echo date("F j, Y | g:i a"); ?></span>
<a href="#">
<?php the_title(); ?>
</a>
</h3>
</div>
</div>
</div>
<?php endforeach; ?>