Wordpress短代码显示发布日期+1天


Wordpress shortcode to display post date +1 day

我正在尝试创建一个显示发布日期+1天的快捷代码。示例:如果帖子是在3号发布的,我想要一个显示第4号的短代码。我试过以下方法,但没有得到我想要的结果。

// [nextday]  
function displaydate_next(){  
    return the_time('jS', strtotime('+1 day')); 
}  
add_shortcode('nextday', 'displaydate_next'); 
// end nextday date

我认为您还需要获得月份和年份,以便它可以计算第二天。以下是您需要的:

// [nextday]  
function displaydate_next(){  
$time = get_the_time('jS F, Y');
$date = strtotime(date("jS F, Y", strtotime($time)) . " +1 day");
return date('jS', $date); 
}  
add_shortcode('nextday', 'displaydate_next'); 
// end nextday date

您可以为此目的使用WP日期和时间短代码。只需添加days="+1"作为属性即可。

例如:[wp-dt item="custom" format="jS" days="+1"]