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
- How to show page content in feed?
- Sanitize and data validation with apply_filters() function
- remove_filter( ‘the_content’, ‘wpautop’ ); only for certain post types
- Valid characters for actions, hooks and filters
- How to hook into unregistering a widget instance?
- How do I use the ‘http_request_host_is_external’ filter
- AJAX filter posts on click based on category
- Can I add custom meta for each image uploaded via media-upload.php?
- How do I know if author field was changed on post save?
- Load different template file when condition met?
- Some questions regarding filter
- Problem getting single_template filter to work – I want to serve a different single.php file for posts in a certain category
- Too many actions/filters!
- Which hook is fired when inserting media into a post
- Admin List Dynamic Heading
- How can override a add_filter of a plugin?
- Adding Filter Conditionally Per Page ID
- How to specify which category of the post to use in case of multiple categories
- Nested calls the the_content filter
- How to change domain used when pinging sites
- return values from hooks do_action and apply_filters, which is better
- Return a custom value in a function added to an action hook
- Using Conditional Statement in functions.php
- get_title without filter(the_title)
- How can filters be run when they are never applied?
- Multiple filters for wp_get_archive
- Add html to cpt main page / admin edit.php
- Filter and modify entry-footer link in twentyseventeen
- Function the_content not working
- Is there a filter called ‘network_admin_init’?
- Break out of wordpress filter
- Manipulating show_on_front, page_on_front, page_for_posts and template hierarchy
- Edit default comments page in WP Admin
- Post Content, Special Characters and Filters
- Add filter problems
- Where is the content cache when using apply_filters(‘the_content…?
- Filter Categories in meta box for CPTs
- How to make custom column Admin>Users sortable?
- How to prepare WordPress Rest data for Preview Changes?
- How to validate recaptcha on comments form?
- Does a plugin with a AJAX button filter exist? [closed]
- Is there any filter to trigger as soon as media is uploaded to post or page?
- add_filter with retrieve_password_message() not working in plugin, but works in functions.php
- Add a div of content within the_content after a certain block
- Gutenberg Block – Post Featured Image Filter Hook
- separate categories with comma and srounded by single quote
- Prevent add_filter being applied to wp-admin pages
- Translate custom order status through a filter?
- Using preg_replace() with the_content filter
- apply_filters(‘get_the_content’, $content) + Except
- Filter everything from content except output of a shortcode
- sortable columns for multiple custom post types not working
- Is there a way to globallly apply esc_html( … ) to all inputs and anchors to filter out XSS markup?
- Filter get_page_by_path()
- Handle multiple parameters in filter
- Want to use wp_get_current_user() in query filter
- WP 4.5 hide core customizer sections
- Apply wordpress filter checking category
- Custom nav walker: How to acces the $args parameter?
- alternative to the_content filter
- How to set a filter search for categories of blog posts in wordpress
- Same URL for portfolio and for a page creates 404 error. Is there any filter that i can use for a child page?
- Filter widget_posts_args not working
- How can I filter the comment action links so that I can display the actions links based on user capabilities?
- Adding link options in insert/edit link dialog window
- WordPress Tag Cloud Filter Prevents Widget HTML from loading
- Using add_filters() , apply_filter(), add_action() and do_action() in extending a plugin
- Hide a specific post from Archive Feed
- How to add a class to Buddypress avatars in the Activity stream? [closed]
- Updating User Profile on Registration
- remove_filter excerpt_more from a plugin class
- ACF Load Field Groups Programmatically [closed]
- Why does using excerpt_more filter change link location?