admin-plugins author calendar category facebook post rss search twitter star star-half star-empty

TIDY REPO

The best & most reliable WordPress plugins

Premium Managed WordPress Hosting
Free

Public Post Preview

Plugin Author: Dominik Schilling

Jay Hoffmann

May 12, 2014 (modified on May 22, 2018)

Admin, Editing

Public Post Preview allows you to easily add a public link to posts, pages and custom post types that have not been published yet and are still in a “Draft” status. So if you need to be able to pass a link around for a client’s approval or to have people look at it before it goes live, this plugin makes it possible.

What’s It Do?

Public Post Preview adds a small checkbox underneath the “Publish” button in the WordPress post editor labeled “Enable Public Preview”. If you check the box, then a URL will be automatically generated for you that links to that page. The advantage is that this public preview can be enabled before the post is properly “published,” meaning that only users that have direct access to the link will be able to see the page. So if you want to check the look of something with a few people before it goes live, you just turn this feature on, then copy and share the URL with your friends before posting it to your final site and officially making it “live.”

Public previews can be enabled for posts, pages, and any custom post types that have the publishing meta box. By default, URLs will remain accessible for 48 hours and then expire, and a new URL will be created. However, you can change this using a filter in your functions.php file.

How’s It Work?

The plugin does not have any settings, so after you install and activate it, you can see it in action by creating a new post, page or custom post type. Just go to Post -> Add New.

Add the content you want, then click the “Save Draft” button in the Publish meta box at the top right of the sidebar. After the draft has been saved, you will see a new checkbox labeled “Enable public preview.” If you check this box, a new text box will appear below it with a randomized URL that looks something like this:

http://mysite.com/?page_id=1358&preview=1&_ppp=46836572b1
Public Post Preview plugin publish button

Just check the box and copy the URL

The URL is intentionally randomized so that it can only be accessed by the people you choose to send it to. If you visit the provided link you will see the full page on your site, even if you are not logged in. But if you visit the front page of your site, you will notice that the post or page has not been published and that there is no way to see it unless you have that link. Simply copy and paste this link anywhere you want to share it, and anybody will be able to see a preview of the page. Click “Save Draft” again to ensure that the public preview is stored.

By default, the URL will last 48 hours, and a new one will be created. However, you can change this using the ppp_nonce_life filter. Open up your functions.php file, and simply add the filter with the new time interval you want it to last. The time is specified in milliseconds, so you will have to do a little fancy math. For instance, the below example extends the URL expiration date to 3 days:

add_filter( 'ppp_nonce_life', 'my_nonce_life' );
function my_nonce_life() {
    return 60 * 60 * 24 * 3; // For 3 days
}

Simply change the “3” to the number of days you want the URL to last before it expires. If you want to expire a link before it is scheduled to be, simply uncheck the “Enable public preview” checkbox and click “Save Draft” again.

Costs, Caveats, Etc.

Public Post Preview is a useful and well-maintained plugin. If you do happen to run into any problems, visit the support forums for help.

Resources

Did you like this plugin?

Plugin Info
  • Downloads: 246,542+
  • Downloads trend (30d): +96.3%
  • Active installations: 50,000+
  • Rating:
  • Last Update: July 20th, 2019
  • Download Plugin for Free