2012-05-22 90 views
0

我的網站上有一個包含事件列表的小插件。我想將上一個/下一個月的按鈕添加到小部件,所以我需要一種方法來篩選當月的事件日曆插件的結果。如何僅從事件日曆wordpress插件顯示當前月份的事件?

有誰知道一種方法來完成這個?我沒有看到可以傳遞給tribe_get_events數組的參數列表。

這是我現在使用的代碼:

global $post; 
$all_events = tribe_get_events(array(
'eventDisplay'=>'all', 
'posts_per_page'=>-1 
)); 

所以我想要做的是一樣的東西:

global $post; 
$all_events = tribe_get_events(array(
'eventDisplay'=>'all', 
'month'=>'may', 
'posts_per_page'=>-1 
)); 

只是沒有完全確定正確的名稱爲參數,只是獲得當前月份。

預先感謝輔助:)

回答

1

我想出如何在與行事曆WordPress插件時間拿到了一個月。

,我使用的代碼看起來是這樣的:

global $post; 

if (isset($_GET['setmonth'])) { 
$current_month = $_GET['setmonth']; // this grabs the month from the url 
} else { 
$current_month = date('M'); // This gets the current month 
} 


$all_events = tribe_get_events(array(
'eventDisplay'=>'all', 
'posts_per_page'=>-1, 
'start_date'=>'01 '.$current_month.' 2012', 
'end_date'=>'31 '.$current_month.' 2012' 
)); 
相關問題