Previewing your WordPress post is an essential part of any editing process. You need to see how it looks, whether the formatting is correct and that it all makes sense. Unfortunately, the WordPress core installation requires that you log in to see the post preview.
However, what happens when you want a third party to check over your post before it is published? Perhaps you need a specialist opinion or want someone to give you a review or check the grammar or spelling.
The old way was to create a user for them to log in, allowing them to preview the post. You’d then delete the user account again.
This is an unnecessarily complicated process, but thanks to some hard work by a developer called Dominik Schilling, we can now access a Preview post in WordPress Publicly.
Public Post Preview Plugin
Dominik Schilling put his mind to the problem and created a plugin called “Public Post Preview,” which is freely available in the WordPress repository. At the date of posting, the plugin has had a total of 20,578 views and is rated 4.8 out of 5 stars.
The plugin creates a shareable link enabling the public to preview the unpublished post without logging in. It is that simple.
The plugin works by using NONCE. You may be asking, “What is a Nonce?”. Well, it stands for “Number used once” and allows specific URL’s be tied to a particular request.
In this case, it allows the post preview to be generated. You can read more about NONCE on the WordPress.org website here.
Installing the Plugin
Just install the plugin via the administration interface, as you would with any other plugin. You can either upload the plugin you downloaded via the WordPress Repository or search for “Public Post Preview,” which will show as the top entry, ready for you to click “install”.
Once installed, there is nothing further to do. To create the shareable public preview URL, click the “Enable public preview” button in the right sidebar under the Publish section.
You can then copy and share the link that shows under the “Enable public preview” tick option. If you no longer wish for the public preview to be accessible, you can deselect it.
You should be aware that the link will only be valid for 48 hours. If you need the public preview to extend beyond this period, you will need to recopy the URL, which will automatically update itself, although there are a couple of ways you can change the expiry date.
How to Change the Default 48-hour Expiry Date for Shareable Links
There are two ways of doing this:
1. Custom changes to the functions.php file
The following snippet of code will extend the NONCE time, which in the example below sets it for five days. You can replace “5” with the required number of days.
add_filter ('ppp_nonce_life', 'my_nonce_life' );
function my_nonce_life() {
return 60 * 60 * 24 * 5; // 5 days
}
2. Public Post Preview Configurator Plugin
Someone took away all the hard work and incorporated the code into a plugin with a simple interface that allows you to choose the number of hours you wish the Public Post Preview link to be active.
Install this plugin as you would any other plugin, and configure it by going to “SETTINGS -> Public Post Preview Configurator”. A screenshot of the configuration screen is below:
As you can see, it makes everything extremely simple.
Video Tutorial
Final Thoughts
This is a plugin that we have used on many occasions to get feedback from third companies on reviews or other tutorials. It makes the process extremely simple, without having to create cumbersome instructions to enable people to log into your WordPress administration area to preview one post.
However, there are some potentially interesting uses for this functionality, such as early access to special members or a page with special offers that are only intended to be active for a short time. While we haven’t used it for anything like that, the use case is there.