The question pretty much got covered in another thread here.
In case anyone else need anything like this I ended up using following code to hide all the posts that are over a week in the future.
function hide_future_posts($where, $q) {
if(is_admin() && $q->is_main_query() && !filter_input(INPUT_GET, 'post_status') && ( $screen = get_current_screen() ) instanceof \WP_Screen && 'edit-post' === $screen->id) {
global $wpdb;
$where .= sprintf(" AND {$wpdb->posts}.post_date <= ( '%s' )", date('Y-m-d', strtotime('+1 week')));
}
return $where;
}
add_action( 'posts_where', 'hide_future_posts', 10, 2 );
Related Posts:
- Add new post with predefined / preset date
- Filter on the day of the week from timestamp
- Filter translations (gettext strings) on specific admin pages
- How to add icons to post listing (edit.php) in admin
- How can I send data to admin-ajax via JS Fetch?
- Filtering admin entries for custom post type
- how to change appearence of the content of default post list columns?
- Change name of existing post status type
- Wrong post_status notice after wp_insert_post_data
- Adding a Clone link to product attributes – post_row_actions() filter, or how to override a Class question
- Filtering the post list in the admin area
- Filter for when the post is updated
- Help with filter for wp_notify_moderator()
- How can I specify the post status of an untrashed post?
- Admin: how to make a custom list filter button send GET queryvars
- Echo string in admin panel footer beside version no
- How can I tranlslate post date in italian?
- WordPress add_filter to post_date
- How to filter page title for certain page?
- Having issue with dynamic data within restrict_manage_posts function
- Admin view: filter posts by whether they have specific taxonomy attached
- How to get to the date of the uploaded file
- Publish button inside custom field group
- wp.getPosts with status = ‘trash’ using node.js
- Admin filter/error if post title is too long
- Date filter for post query not filtering results when variable outside the function
- Remove pipe in views admin page filter
- Disable emojicons introduced with WP 4.2
- How to remove a filter that is an anonymous object?
- Add filter menu to admin list of posts (of custom type) to filter posts by custom field values
- WordPress hooks/filters insert before content or after title
- How to add defer=”defer” tag in plugin javascripts?
- add_action(), add_filter() before or after function
- apply_filters(‘the_content’, $content) vs do_shortcode($content)
- How do filters and hooks really work in PHP
- Trouble understanding apply_filters()
- What is the very earliest action hook you can call?
- How would one modify the filtering Gutenberg applies to pasted content?
- How can I modify the WordPress default widget output?
- Add custom options to the wplink dialog
- Remove classes from body_class
- what is __return_false in filters
- Explanation for apply_filters function and its variables
- Gutenberg: Is there a way to know if current block is inside InnerBlocks?
- How to reorder billing fields in WooCommerce Checkout template? [closed]
- Insert HTML just after tag
- the_content and is_main_query
- Filter by custom field in custom post type on admin page
- Changing WooCommerce Display Price Based on User Role & Category [closed]
- How to add a custom CSS class to core blocks in Gutenberg editor?
- How to show page content in feed?
- wp_headers vs send_headers. When to use each?
- Filter any HTTP request URI?
- How to Pass External Variables to Filters/Actions
- How to filter users on admin users page by custom meta field?
- Filter by one custom field, order by another?
- Not able to change wp_title using add_filter
- Update post counts (published, draft, unattached) in admin interface
- How to appending to the_content using add_filter with custom post type?
- Query WP REST API v2 by multiple meta keys
- No filter of code on switch from html to visual editor, how?
- Sanitize and data validation with apply_filters() function
- How to modify posts_where filter only for the search query
- How to hook a filter to catch get_post_meta when alternate a custom field output?
- How to get shortcode’s input values inside a filter?
- Removing Image and Caption Dimension Attributes
- How to wrap oEmbed-embedded video in DIV tags inside the_content?
- How to bulk delete all users with no posts?
- How many filter/action hooks are healthy?
- WordPress 3.9 – Trouble Editing TinyMCE 4.0
- Changing JPEG compression depending on image size
- How to add filter with 2 args?
- Why is javascript allowed in my post content?
- How to use update_{$meta_type}_metadata filter to modify meta value
- How to wrap an element around an iframe or embed in content automatically?
- Filter specific shortcode output?
- WordPress Internal @ Mentions
- How to add headers to outgoing email?
- Earliest hook to reliably get $post/$posts
- Insert new element to array with add_filter
- LESS CSS enqueue_style with add_filter to change rel attribute
- Is it possible to filter comments in a post so a user can only see the comments they have written?
- How to pass/get data to/from the WooCommerce data-product_variations object?
- Remove Editor From Homepage
- How to modify Contact Form 7 Success/Error Response Output [closed]
- Where to hook into post content?
- What does (10, 2) mean when used with add_filter
- Filter username field on registration for profanity and unwanted words
- Clarification on filters and hooks
- How to order posts of a custom post type by date DESC in dashboard Admin?
- remove_filter( ‘the_content’, ‘wpautop’ ); only for certain post types
- At what priority does add_filter overwrite core functions?
- Custom column for changing post status via ajax
- Change admin bar to default:off
- Valid characters for actions, hooks and filters
- is it possible to add “extra” table nav to edit-tags.php screens?
- Advanced Custom Fields and Yoast SEO keyword analysis [closed]
- Adding a filter to qTranslate to change display of language chooser
- Insert Custom HTML After Shortcode
- Modify links when inserted by WYSIWYG editor