Keep things simple – leave your archive templates alone and place this in your functions.php
;
add_action( 'pre_get_posts', function ( $wp_query ) {
global $wp_post_statuses;
if (
! empty( $wp_post_statuses['future'] ) &&
! is_admin() &&
$wp_query->is_main_query() && (
$wp_query->is_date() ||
$wp_query->is_single()
)
) {
$wp_post_statuses['future']->public = true;
}
});
Essentially, it says;
If we’re on a date archive, or viewing a single post, make future posts publicly visible.
As a result, WordPress behaves normally when you view archives for any given date, except now it also includes posts ‘from the future’!.
Related Posts:
- How do you split multiple-column loop on category archive page?
- Adding active/current class to get_terms list
- Duplicated posts on category page
- Order archive results by post id in custom taxonomy template
- Default ‘post’ post type archive slug?
- Update status of all posts in a category
- How to display pending posts on the homepage only for editors
- First archive page with a few posts
- Query Nopaging action not having effect
- get_comments with post_status ‘public’ retrieves NULL result
- Include future posts in tags and in search
- add offset to archive page
- Modify loop output for a specific list of categories
- Is it possible to set archive.php instead of index.php to display blog?
- Duplicate posts on archive page
- Archive: Lists itself
- Archive sorted by month – separate
- Creating a archive for taxonomy terms, not the term results
- wordpress showing all posts instead of date range
- Retrieve each widget separately from a sidebar
- Should I use loop in the single.php file?
- how to upload image using wp_handle_upload
- Avoiding using a loop to access a single post
- Adding ‘current_post_item’ class to current post in the loop
- Display all authors and their only one latest post
- Remove comma from last item output from loop
- Getting page ID inside loop
- Can’t get drafts with WP_Query using post_status parameter
- How to show just private posts in loop
- How to paginate this custom loop? [duplicate]
- Can I use both a custom excerpt and a trimmed excerpt?
- Select data from database and list it in Loop (WordPress)
- wp alchemy multiple image uploader output images to template
- Running a loop with a custom query string on a custom page template
- I’ve been out of the loop since 2.8. What did I miss?
- Loop first six posts in carousel, next eight in grid
- Infinite blog loop
- One custom loop with condition to check child posts
- Loop get_theme_mod
- Move sticky posts down in main loop
- Why only one post (and no pagination) on this variation of the loop?
- Displaying terms based on loop posts?
- Custom post type appearing within the previous one on archive.php
- How do I go about looping through a advanced custom field on a particular page inside of another page
- Template structure
- The Loop – mixed ASC and DESC order
- Filter the_posts doesn’t work on search page
- Custom Loop Using Shortcode in Custom Page Template
- Cannot retieve the_content() and the_author() – both returning empty strings
- Pagination not working in category listing [duplicate]
- How to get the excerpt for is_home() outside of the loop isn’t working
- Make loop alphabetical
- How to check if a product is purchased within the last 365 days before displaying something
- How do I get my loop.php to properly paginate?
- Category links including all posts
- Custom loop ordering not working
- Hiding a row in the loop if empty
- Loop through ACF taxonomies and output associated posts
- How to get user ID’s from multiple usernames?
- Query posts only with actual text content (not including shortcode or images)
- How can this multiple loop have pagination as described?
- Default featured image set as background image [closed]
- Breaking up the results of a loop
- How do i create a list-posts-page?
- Exclude posts based on an array
- Is file_exists() compatible with timthumb.php? [closed]
- How can I increase the post count for custom post types only?
- List ALL posts by author on author archive
- Using is_page_template inside loop
- Set depth of pages to fetch
- Trying to get all links in my posts
- Creating a User-Adjustable chart in WordPress
- How to show the last article in a different way in my blog?
- Can’t limit posts_per_page in loop
- Reorder posts in a loop: have the posts by one particular author below the others
- Slug is changing when I use WP_Query in a metabox of a post
- how to get author comment inside the loop?
- How to create loop in custom page, and get id from url into this loop?
- How to fix pagination for custom loops?
- Check to see if a field is within an array in twig
- Display single post inside accordion based on form submission results
- One page loop issue with posts
- Humanmade | Custom meta box class: How to display a repeatable meta box group?
- Can’t print out returned value
- change the_content images for different sizes (Desktop, tablet, mobile)?
- Building theme so user can change header image [closed]
- Get query result before posts are displayed?
- WordPress Group By Problem
- Home page loop with pagination problem
- WooCommerce custom loop pagination on front page
- get_page() unlike Loop returns the post content without html tags. How can I fix this?
- Problem with ms-thumb-frame-selected class in Master Slider
- I want the first post on my home page to be lengthier than the rest (example included)
- Loop with Custom Post Type Taxonomies and Interstitial Code
- Question about custom plugin
- Display all posts in a page code for template
- How can you make it so the comment box shows on some pages or posts but not all?
- How to use orderby on meta_value when using Pods custom database table storage
- wp_mail function not working in user query loop
- How to set and retrieve cookies while in the loop