2017-04-03 162 views
0

所以我需要使按鈕或鏈接將更新發布發佈日期。如何更新發布日期發佈日期點擊wordpress

我發現這個,但我不知道如何調用它。

$time = current_time('mysql'); 

wp_update_post(
    array (
     'ID'   => $id, 
     'post_date'  => $time, 
     'post_date_gmt' => get_gmt_from_date($time) 
    ) 
); 
+0

您可以查看[http://stackoverflow.com/questions/13114270/wordpress-plugin-how-to-因爲你的問題與此相似,所以你需要更改日期時間(http://stackoverflow.com/questions/13114270/wordpress-plugin-how-to-change-the-post-date-time)。 – Ninja

回答

0

請檢查:

$mypost = array(); 
$mypost['ID'] = 1; // the post ID you want to update 
$mypost['post_date'] = $your_date; // uses 'Y-m-d H:i:s' format 
wp_update_post($mypost); 

希望這有助於..

+0

謝謝,它的工作 –

+0

歡迎您:) – Aaron