2016-04-03 81 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 行为正常,除了现在 它还包括“来自未来”的帖子。

相关问题