如何检查某个帖子是否在特定年份?如果单个帖子在特定年份,我需要输出一些代码。
答案 0 :(得分:0)
在wp循环内部,您可以使用内置的wp functino the_date(' Y')
获取帖子的日期所以在wp循环中只需查看日期==是这样的。
<?php
if ( have_posts() ) {
while ( have_posts() ) {
if(the_date('Y') == '2015'):
the_post();
else:
continue;
endif;
} // end while
} // end if
?>