允许未登录的用户在点击未来帖子列表后查看未来帖子

时间:2012-01-28 作者:Chris Butler

我可以在如下自定义模板中列出为将来设置的页面:

query_posts(\'post_type=page&post_status=future&posts_per_page=100&order=asc&orderby=date&meta_key=_wp_page_template&meta_value=show.php\');
然而,当我尝试单击其中一个页面时,我得到了404(作为未登录用户)。

如何更改主题page.php 显示未来页面的模板?

我们已经在function.php 并为这种特殊类型的帖子提供一个特殊的页面模板。。。

我尝试将以下内容添加到functions.php 具有add_filter, 但这没有帮助:

function show_future_where($where) {
    return $where . \' AND (wp_posts.post_status = \\\'publish\\\' OR wp_posts.post_status = \\\'future\\\')\';
}
顺便说一句,我看到一篇关于自动设置未来日期的帖子将被“published”状态覆盖,但无法实现。

如果我可以编辑页面模板,我还能做些什么吗?

如果有帮助的话,我正在使用3.3。

谢谢

1 个回复
SO网友:Jennifer M John

试试这个:

$my_query = new WP_Query(array(
    \'post_status\' => \'future\',
    \'order\' => \'DESC\',
    \'posts_per_page\' => 1,
));
while ($my_query->have_posts()) {
    $my_query->the_post();
    the_date();
    echo \' - \';
    the_title();
}
wp_reset_postdata();
或者这个:http://wordpress.org/extend/plugins/show-future-posts-on-single-post/

结束