1

I have a blog and I make posts daily, and I would like for users to be able to access posts one day before they are published. How can I do that?

  • Which users and how? – Tom J Nowell Aug 15 '17 at 16:50
  • Any registered user. – NerdOfLinux Aug 15 '17 at 16:50
  • And were you thinking of a shortcode, widget, page template? These are scheduled posts? – Tom J Nowell Aug 15 '17 at 17:03
  • Yes, they're scheduled. – NerdOfLinux Aug 15 '17 at 17:22
1

You can use this in a template file:

$tomr = getdate(time()+86400); //utc=gmt time in seconds, add 24 hours = 86400 seconds
$args = array(
  'post_status' => 'future',
  'date_query'  => array(
    array(
        'year'   => $tomr['year'],
        'month'  => $tomr['mon'],
        'day'    => $tomr['mday'],
        'column' => 'post_date_gmt' //since we are using the gmt timestamp
    ),
  ),
);
$query = new WP_Query($args);
if($query->have_posts()) {
  while($query->have_posts()) {
    $query->the_post();
    //display post data
  }
  //restore original post data if it's required after this loop
  wp_reset_postdata();
} else {
  //no posts found
}
1

Here are a few plugins that may be useful to you:

I prefer WP-DraftsForFriends as it has an admin page to control expiration and renew for longer periods of time. It's also nice to see all of your public links in one area rather than Public Post Preview which is only controlled on the post edit screen.

0

You can just add a post in admin and give post link to user, Like suppose you want to publish post tomorrow then just create post and put publish date for tomorrow. So post will publicly displayed tomorrow. but you can share that post link to anyone.

  • As far as I understand, only admins can see the post before its published with the URL. – NerdOfLinux Sep 8 '17 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.