Alright, so it’s doable but needs a few tweaks.
First, you’ll want to hook into recently_pre_get_posts to have Recently fetch future posts. This is how it’s done:
/**
* Have Recently return future posts
* for widget instance ID 'recently-2'
*
* @param array $args The args passed to WP_Query.
* @param string $widget_id The ID of the current widget instance.
* @return array
*/
function recently_get_random_posts( $args, $widget_id ){
if ( 'recently-2' == $widget_id ) {
$args['post_status'] = 'future';
$args['orderby'] = 'date';
$args['order'] = 'ASC';
}
return $args;
}
add_filter( 'recently_pre_get_posts', 'recently_get_random_posts', 10, 2 );
Notice how the code checks which widget is being rendered. If it’s the one with ID recently-2 then it’ll set the variables we need to have this particular widget list future posts instead of recently published ones (I figured you may want to use another Recently widget to list recent posts and so this allows you to do just that.)
You can get the ID of the widget you want to use to list future posts either by adding the widget to your sidebar, then check the source code of your homepage (or wherever your sidebar is) to find the ID of the widget. Or you could just install the Get Widget ID plugin and see the ID right on the Widgets screen.
Make sure to use the right ID for all this to work ??
Note though that Recently will render your future posts just like it would regular, published posts: with links. Since your future posts haven’t been published yet WordPress will use “ugly” URLs instead (eg. https://www.example.com/?p=3464
.) If a visitor clicks on said ugly links they’ll be able to see the post, something I’m guessing you don’t want to happen ??
If you’re using the built-in themes (eg. Cards), you’ll want to replace any instances you find of the following Content Tags:
… with their no-link counterparts:
Yes, the design will change slightly as you’re replacing elements here but visitors won’t be able to read future posts ahead of time ??
It is possible to re-style the theme after these changes, however you’ll need at least some HTML/CSS knowledge to do so (or find/hire someone who knows.)
If you have any questions don’t hesitate to ask.
-
This reply was modified 4 years ago by
Hector Cabrera. Reason: Fixed link
-
This reply was modified 4 years ago by
Hector Cabrera. Reason: Reworded for clarity