I installed a WordPress for a domain name. When I use this domain name will point to index.php in my template. I want show a under construction page for this domain name, but the other hand I still want work on index.php in my template.

5 s
5

You can filter template_include and include a special file for users who are not logged in:

/* Plugin Name: T5 Under Construction */

add_filter( 'template_include', 't5_uc_template' );

function t5_uc_template( $template )
{
    $uc_template = dirname( __FILE__ ) . '/under-construction.php';

    if ( ! is_user_logged_in() )
        return $uc_template;

    if ( ! current_user_can( 'administrator' ) )
        return $uc_template;

    return $template;
}

The file under-construction.php could be a plain HTML file; it doesn’t have to be a PHP file.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *