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
- Different date time in results of search
- How to fix pagination for custom loops?
- Jquery Slider for profile template
- Counting the posts of a custom WordPress loop (WP_Query)?
- if ( is_home() && ! is_front_page() )
- Get excerpt using get_the_excerpt outside a loop
- How to display Yoast SEO meta description in archive template for each post instead of the_excerpt()? [closed]
- Get post content from outside the loop
- Can I force WP_Query to return no results?
- Why should I put if(have_posts()), is while(have_posts()) not enough?
- Display featured products through custom loop in woocommerce on template page
- Split Content and Gallery
- How to get Author ID outside the loop
- How can i display the content in plaintext
- Redirect loop when trying to login to /wp-admin/ [duplicate]
- How to split a loop into multiple columns
- Is it necessary to reset the query after using get_posts()?
- Is there any difference between the_title() and echo get_the_title()?
- AJAX with loop filtering categories
- Do I need to use The Loop on pages?
- Remove the Homepage Query
- remove tags from the_content
- group search results by post type?
- the_title() shows title of the first post instead of the page title?
- How to force excerpts / teasers in the loop
- Retrieve each widget separately from a sidebar
- Why doesn’t wp_update_post() update the post_status field?
- Why am I being limited to ten posts on a custom loop?
- Exclude Specific Term from Search
- Should I use loop in the single.php file?
- Why do themes rely on “The Loop”?
- How to return loop contents
- Using the Loop to show all levels of subpages under a parent page? Halfway there
- Cleanest Way to Select Every Second Element in a Loop?
- Insert image or ad script after 3 posts using the loop
- Get date of last update outside of loop
- Pagination not working on home page
- Child Pages Loop
- How to place comments_template(); outside the loop?
- Multiple Loops Homepage?
- How to Change Loop to Order Posts by Views (using wp-postviews plugin)
- how to upload image using wp_handle_upload
- Avoiding using a loop to access a single post
- Executing Queries in tag.php
- How to get the first image gallery of a product in woocommerce in a loop
- Get post by page name or slug
- save_post + insert_post = infinite loop
- How to order posts tag by tag?
- Loop.php vs looping inside template file
- Get ID of a page containing secondary loop in content
- How to search for categories and/or tags?
- Custom Loop and Infinite Scroll
- Loop that displays PARENT PAGE & CHILD PAGE & outputs GRANDCHILD PAGE title and content
- is_home, and is_front_page conditional problem
- Is `query_posts` really slower than secondary query?
- Are there any scenarios where the query_posts may be used?