Skip to content

Instantly share code, notes, and snippets.

@jtcote
Last active August 29, 2015 14:16
Show Gist options
  • Save jtcote/4145595d1ef73f2840fe to your computer and use it in GitHub Desktop.
Save jtcote/4145595d1ef73f2840fe to your computer and use it in GitHub Desktop.
WP maintenance page redirect function
/***** MAINTENANCE *****/
//* Redirect for temp landing page
add_action( 'template_redirect', 'gum_redirect_maintenance_page' );
function gum_redirect_maintenance_page() {
$redirect = FALSE;
$page = home_url( '/maintenance/' ); //slug for wp page
if ( $redirect && !is_user_logged_in() && trim( $_SERVER['REQUEST_URI'], '/' ) != 'maintenance' && $_SERVER['REQUEST_URI'] != '/wp-admin/' ) :
wp_redirect( $page );
exit;
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment