您可以使用get_{$adjacent}_post_where
滤器
基本上,我们所做的就是将查询中的“查找已发布的帖子”部分替换为“查找已发布或未来的帖子”。
/**
* Amend the \'WHERE\' clause in the SQL query to find an adjacent post
*
* @param required string $where The default \'WHERE\' clause in the query
* @param boolean $in_same_term Whether or not the adjacent post should be in the same taxonomy term (not required here)
* @param array $excluded_terms The ID\'s of terms that should be excluded (not required here)
* @return string The updated, custom \'WHERE\' clause
*/
add_filter(\'get_previous_post_where\', \'my_add_future_posts_to_nav\', 3, 99);
add_filter(\'get_next_post_where\', \'my_add_future_posts_to_nav\', 3, 99);
function my_add_future_posts_to_nav($where, $in_same_term, $excluded_terms){
return str_replace("p.post_status = \'publish\'", "p.post_status IN (\'publish\', \'future\')", $where);
}
虽然我似乎找不到任何筛选器引用
get_{$adjacent}_post_where
, 有一个
Developer Code Reference 你可能会发现这很有用。