To achieve the intended result you will have to modify the query by adding the future
value to the post_status
parameter via the pre_get_posts
filter hook.
add_action( 'pre_get_posts', 'se338152_future_post_tag_and_search' );
function se338152_future_post_tag_and_search( $query )
{
// apply changes only for search and tag archive
if ( ! ( $query->is_main_query() && (is_tag() || is_search()) ) )
return;
$status = $query->get('post_status');
if ( empty($status) )
$status = ['publish'];
if ( !is_array($status) )
$status = (array)$status;
$status[] = 'future';
$query->set('post_status', $status);
}
Conditional tags is_search()
and is_tax()
will allow you to modify the query only on the search page or the tag archive.
Related Posts:
- A search for ‘0’ returns results
- Show scheduled posts in archive page
- Related Posts loop – offset
- If No Search Results, Show Posts from Alternate Search Query
- Custom search form to display users only
- Get titles of all posts with current tags except current post
- taxonomy tags 404 to custom post types
- How to get an array of years from all of the search results, and use it to filter by year the paginated loop?
- A loop with all articles with certain text strings in tags
- How to go about combining dropdowns / filter queries?
- Get search.php results in header.php?
- How to show posts with multiple tags on tag.php?
- Filter the_posts doesn’t work on search page
- Problem getting current post tags to show in a widget
- How to show more random posts if Tag has less than 3 posts
- Update status of all posts in a category
- Exclude page name from loop
- How to display pending posts on the homepage only for editors
- Display Posts Only with Specific Tag
- How to modify search.php to not show pages only show posts
- how to replace get_template_part(‘loop’,’tag’) with explicit styled version?
- For each loop on every word in post
- Tags on page (not post) returns nothing – why? Improved clarified question!
- get_comments with post_status ‘public’ retrieves NULL result
- Show scheduled posts in loop (but don’t link to them)?
- Search page loop banner image issue
- how to run loop in function.php that sends email based on specific conditions?
- Does search.php autofilter The Loop?
- Using has_tag() outside loop
- How do I set the Stewart Search Template to return only published posts in the result
- Trying to get all links in my posts
- Adding $args to wp_schedule_event() causes hook to add infinitely to WP Cron
- Work arounds for conditional checks inside the loop in search.php?
- Search – Check if post is a page on search page
- Show posts by tags excluding current post
- WordPress Tags in class
- Secondary loop cuts off at 10 posts?
- Related posts by searching post tags of single post as terms
- How to show only specific tag in wordpress loop
- Eliminate duplicates in a foreach loop [closed]
- Tag custom loop show posts
- get_page() unlike Loop returns the post content without html tags. How can I fix this?
- How to do query_posts on tags pages
- Tags outside the loop
- How to display Yoast SEO meta description in archive template for each post instead of the_excerpt()? [closed]
- How to place comments_template(); outside the loop?
- Endless loop with wp_insert_post and wp_update_post
- Hook into the loop via a plugin, and output something after every X post?
- Two custom loops, pagination, offset
- Access to Media Library
- Getting two wp_link_pages output
- Run The Loop over array of post objects
- Enable infinite scroll on single.php [closed]
- How to loop through ALL pages?
- Does get_template_part pull data once in a loop?
- How to retrieve “sticky” post outside the “loop”?
- Using get_the_excerpt() Before The Loop
- code suddenly appearing from my tempate second loop
- wp_query inside the_loop
- woocommerce get_price_html not pulling in correct price
- How to fix pagination for custom loops?
- WordPress Rewriting the DOM?
- How to display posts by vote count and if no value continue with latest posts with no votes?
- Sort results by groups of numbers and letters
- Modify the main loop to display current month / year
- Display post list with different styles
- Loop for sticky posts
- Pagination Error : Duplicate argument being outputted
- Array ids post to function have_post
- Give each posts in a loop a number in sequence
- custom post on homepage
- Category ID returns as ‘0’?
- Show terms in archive page
- Loops for cat links not looping for wordpress site
- Skip 5 latest post while paging?
- Sort posts according to a numeric value entered with ACF
- wp_get_attachment_url not fetching URL?
- get the value for ALT is we check to see if an actual ALT value is set, if not we use the caption and if no caption is set we use the title
- How to get all multi-select user meta values and add them to an array?
- How to resolve a reload loop issue in the frontend when logged in to WordPress multi-site backend admin area
- Exclude Posts Using Meta Query and User Meta
- Excerpt isn’t working or am I missing something?
- Can I temporarily disable global $post?
- Shortcode for pulling specific Post Title outside loop when ID is passed in
- Can I Paginate Post after every 25 tag?
- Show a list of user posts in the user admin page
- Infinite Loop after Genesis Theme Upgrade
- Active class for my flexslider in WordPress
- WordPress loop only displays 5 articles max?
- get_template_part() to render single page Theme
- Can’t see custom field after the Loop [closed]
- Showing related posts (custom post type) outside of the loop
- Same Loop on Multiple Pages
- Paged homepage – requirements?
- Least Number of Loops to Create Custom Homepage?
- The Loop for my theme with static front page is not working
- WordPress loop: Display if posts exist
- Showing ads after posts in home page
- Prevent duplicating specific column from database table
- Hook in the loop after the first post