How to set up a Coming Soon page
This simple tutorial will guide you on how to restrict access to only logged-in administrators and redirect all other visitors to a ‘Coming Soon’ page while you’re still working on your site.
- We’re not going to use any Coming Soon plugin. Instead, we’ll use a code snippet. Please install and activate this code snippet plugin if you haven’t already. You can refer to this article to learn more about what a code snippet plugin is all about . You will be able to use it for more than just a Coming Soon page.
- You’ll also need to have a static Coming Soon page set up with the slug or permalink ‘coming-soon’.
- Navigate to Snippets > Add New
- In the Snippets Title field, enter a name such as ‘Coming Soon‘ or ‘Maintenance Mode‘.”
- Enter the following code in the code box, choose ‘Run snippets everywhere‘, and click the ‘Save changes and active‘ button.
function ss_custom_coming_soon_page() {
if (!is_user_logged_in() || (is_user_logged_in() && !current_user_can('administrator')) && !is_page('coming-soon')) {
wp_redirect(home_url('/coming-soon'));
exit();
}
}
add_action('template_redirect', 'ss_custom_coming_soon_page');
Make sure to replace ‘coming-soon’ with the actual slug of your “Coming Soon” page if it is different.

You can switch this option ON or OFF whenever you need to enable or disable this function.