1

There are some posts dated on future year. I would like to show them. What have I done so far:

add_filter( 'getarchives_where', 'displayFuturePosts', 10, 2 );
function displayFuturePosts( $text, $r ) {
    return "WHERE post_status = 'future' OR post_status = 'publish'";
}
wp_get_archives(array( 'type'=>'yearly' ));            

This show three links: 2016 2017 2018

First two opens and shows all the posts, but 2018 redirects to 404.

1

You need to add future posts to the query.

function add_future_posts($query) {
    $query->set('post_status', array('publish', 'future'));
}
add_action('pre_get_posts', 'add_future_posts', 10, 1);
| improve this answer | |
  • Just add the code I gave you to the functions.php – Shibi Dec 7 '17 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.