2016-04-03 111 views

回答

0

使用post_status=future與標準的Wordpress query_posts。見https://codex.wordpress.org/Post_Status

這是10個職位有錯誤「沒有職位」的消息,標題和日期一個簡單的例子循環:

<?php query_posts('posts_per_page=10&post_status=future'); ?> 

<?php if (have_posts()) : while (have_posts()) : the_post(); ?> 

<h2><?php the_title(); ?></h2> 

<span class="datetime"><?php the_time('j. F Y'); ?></span></p> 

<?php endwhile; else: ?> 

<p>No future events scheduled.</p> 

<?php endif; ?> 

這可能是更你在找什麼。這是一個包含日期歸檔和單個帖子的未來帖子的功能。放入functions.php文件的主題:

if (!is_admin()) : 
function __include_future($query) 
{ 
    if ($query->is_date() || $query->is_single()) 
     $GLOBALS[ 'wp_post_statuses' ][ 'future' ]->public = true; 
} 
add_filter('pre_get_posts', '__include_future'); 
endif; 

https://wordpress.stackexchange.com/questions/16794/show-scheduled-posts-in-archive-page

從本質上講,它說,「如果我們在約會存檔,或查看單個 後,使以後的文章中公開可見。」因此,當您查看任何給定日期的檔案時,WordPress 行爲正常,除了現在 它還包括「來自未來」的帖子。

相關問題