2012-03-02 64 views
0

是否有可能在未來的某個日期/時間更新已經存在和發佈的帖子?在更新完成之前,以前的版本應該可以在網站上看到。在Wordpress 3中安排更新帖子?

可能嗎?

謝謝!

回答

1

不知道這是你在尋找什麼,但這裏有一個插件,它允許你安排一個頁面的一部分或交使用簡碼:http://wordpress.org/extend/plugins/scheduled-content/

它的工作原理是這樣的:

<p>This paragraph is visible by default.</p> 

[schedule on='2012-03-20' at="07:00"] 
<p>This paragraph will be published on March 20th at 7 am.</p> 
[/schedule] 
+0

是的,這是一個開始,我今晚試試。 – EOB 2012-03-02 14:34:59

0

它會始終是相同的職位,將得到更新?在這種情況下,只需要創建一個功能,它掛接到wp_cron.php,點擊這裏http://codex.wordpress.org/Function_Reference/wp_schedule_event 文檔中的一個例子是這樣的(把你的functions.php)

// first parameter is when it should occur, you can set this for example 
// by using php's time(), which will fetch the current time, then add how much 
// further in time you want the event to occur (in seconds). 
wp_schedule_single_event(time()+600, 'function_that_get_called'); 

//the above code will run 10 minutes after functions get called. 

function function_that_get_called() { 
    $my_post = array(); 
    $my_post['ID'] = the_post_id; // the ID of the post you wish to update. 
    $my_post['post_content'] = 'New content for my post!'; 
    wp_update_post($my_post); 
} 

問題與使用WordPress自己的cron功能大多數人訪問過你的網站讓它觸發,但是我猜你可以將上面的代碼添加到你的functions.php文件中,保存並在之後自己訪問網站,它會觸發。 確保添加類似的功能:

error_log('my_scheaduled_event triggered!'); 

所以,你可以檢查你的PHP錯誤日誌和看到函數實際上正確觸發。

相關問題