2016-03-21 29 views
0

有沒有辦法做到這一點?WordPress:按月發佈帖子?

August 2009 
11 Title of the post of the 11th day of August 
15 Title of other post of the 15th day of August 
20 Title of another post of the 20th day of August 

July 2009 
4 Title of the post of the 4th day of July 
7 Title of other post of the 7th day of July 
15 Title of another post of the 15th day of July 

我需要這組通過後定製metabox evmeta_test_textdate

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
$format_of_date = 'Y/m/d'; 
$oldest = date($format_of_date, strtotime('-30 days')); 
$args=array(
    'meta_key'=> 'evmeta_test_textdate', 
    'meta_value'=> $oldest, 
    'meta_compare'=> '>=', 
    'post_type' => 'upg', 
    'post_status' => 'publish', 
    'order' => 'ASC', 
    'paged' => $paged, 
); 
$query = new WP_Query($args); 

謝謝!

回答

0

WordPress的默認行爲是按出版日期和查詢的格式如下處理日期:

$args = array(
    'date_query' => array(
     array(
      'year' => 2012, 
      'month' => 12, 
      'day' => 12, 
     ), 
    ), 
); 
$query = new WP_Query($args); 

有爲什麼要處理的自定義元日期的特別的原因?

+0

我需要從自定義元獲得帖子,因爲這個帖子的事件 –

+0

無論你的帖子是什麼,它仍然有一個WP日期。看看這篇文章:http://www.noeltock.com/web-design/wordpress/custom-post-types-events-pt1/ – patito

+0

我需要一年中的所有月份,,,不只是一個月!我需要(1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12) –

相關問題