Viewing 4 posts - 1 through 4 (of 4 total)
  • #20446
    igorkraev
    Member
    Post count: 14

    Hi,

    How to change maintenance page content?
    I try to create a file in wp-content named maintenance.php, but nothing changes.

    Thanks

    #20695
    Melanie – SUPPORT
    Member
    Post count: 11032

    The content of the file is defined in functions.php

    Cheers!

    #33968
    icr8
    Member
    Post count: 27

    Hello Igor.

    I managed to fix this issue, and here’s how I did it, just for the benefit of you and others that might want to do the same.

    The problem is that the theme overrides the wordpress config settings with a section in the theme functions.php file. Since it is not advisable to change functions.php directly, the following solution worked for me.

    • 1. Create a child theme including a blank functions.php file
    • 2. Create a blank maintenance.php file (containing the content you want to be displayed in maintenance mode)
    • 3. Upload all the assets required for displaying the maintenance page (e.g. images, css, etc) into your child theme directory
    • 4. Upload the maintenance.php file into the wp-content directory, ensuring that the links reference the correct assets folder in your theme directory, to pull in all the required images and css
    • 5. Copy the code below into the functions.php file in your child theme, and save it. (Or add it to your functions.php file if you already have an existing child theme with custom functions)
    • 6. Enable maintenance mode in the theme options, and delete cache to see the changes. (Note you will not see it if logged in as admin, so either log out first before previewing, or open your site in another browser where you are not logged in as admin)
    <?php
    
    /* CUSTOM MAINTENANCE MODE 
    =================================================== */
    	
    	function custom_maintenance_mode() {
    		
    		$options = get_option('sf_neighborhood_options');
    
    		if (isset($options['enable_maintenance'])) {
    		$maintenance_mode = $options['enable_maintenance'];
    		} else {
    		$maintenance_mode = false;
    		}
    		
    		if ($maintenance_mode) {
    		
    		    if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {
    		 	if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
    				require_once( WP_CONTENT_DIR . '/maintenance.php' );
    				die();
    		    } 
    		    }
    	    
    	    }
    	}
    	add_action('get_header', 'custom_maintenance_mode');
    	
    	
    ?>

    I hope you find this helpful.

    Just reply if you have any issues, and will help if I can! 🙂

    #34223
    Melanie – SUPPORT
    Member
    Post count: 11032

    Fantastic, thanks mate!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register