Maintenance Mode won’t work! My theme is twenty twenty two. I pasted into the functions.php. My site is still visible, but now with this message at the top of the page. Any advice? I thought this would make it so the site won’t be visible at all. Trying to use code not a plug-in.

Maintenance Mode won’t work! My theme is twenty twenty two. I pasted into the functions.php. My site is still visible, but now with this message at the top of the page. Any advice? I thought this would make it so the site won’t be visible at all. Trying to use code not a plug-in.

3 Comments
  1. You have not added the code correctly. It’s also not very good code.

    Try this. Create a page. Add a ‘back soon’ message (and any other info you want). Check the ID of the page (hover over the ‘edit page’ item and look at the message bottom of screen)

    Add this code to your functions.php – change **both** 707 for your actual page ID

    `add_action( ‘template_redirect’, function() {`
    `if ( is_page( 707 ) ) {`
    `return;`
    `}`
    `if (!current_user_can(‘edit_themes’) || !is_user_logged_in()) {`
    `wp_redirect( esc_url_raw( home_url( ‘index.php?page_id=707’ ) ) );`
    `exit;`
    `}`
    `} );`

  2. Firstly it looks like you’ve not added the code properly.

    Secondly, you need to check the logged out state to see what the public sees.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Your Advertisement Here