wordpress 发布五天内的文章输出特定内容

如题,我需要发布在五天以内的文章千年加个New的小图标,则可以用一下代码实现。

<code><?php 
    $t1=$post->post_date; 
    $t2=date("Y-m-d H:i:s"); 
    $diff=(strtotime($t2)-strtotime($t1))/7200; 
    if($diff<120){
        echo 'new';
    } 
?></code>

0 thoughts on “wordpress 发布五天内的文章输出特定内容
添加一条新回复 回到顶部

亲爱的,主人已经关闭了这篇文章的评论 。