过滤内容post_class()
:
add_filter( \'post_class\', function( $classes ) {
if ( is_singular() )
return $classes;
// now minus last mod time in seconds
$diff = time() - mysql2date( \'U\', $post->post_date );
if ( DAY_IN_SECONDS <= $diff )
$classes[] = \'new-post\';
return $classes;
});
现在,在您的循环中,使用
post_class()
, 您还可以在样式表中使用一个额外的类:
.new-post {
padding-left: 20px;
background-image: url(new.png) left top no-repeat;
}