Skip to content

Instantly share code, notes, and snippets.

@alanef
Created October 7, 2018 22:19
Show Gist options
  • Select an option

  • Save alanef/045d34364521ea1f9cae2d2653f0d8ae to your computer and use it in GitHub Desktop.

Select an option

Save alanef/045d34364521ea1f9cae2d2653f0d8ae to your computer and use it in GitHub Desktop.
Redirect All Pages
<?php
/**
* Plugin Name: Redirect Everything to Home
* Plugin URI: http://fullworks.net/wordpress-plugins/redirect-404-error-page-to-homepage-or-custom-page/
* Description: Redirect Everything to Home
* Version: 1
* Author: Fullworks
* Author URI: http://fullworks.net/
* License: GPL-3.0+
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt:
*
* No warantee
*
* Redirects all pages to the fromt page with 301, but still allows login
*
*/
add_action( 'template_redirect', function () {
if ( ! is_user_logged_in() && ! is_front_page() ) {
wp_redirect( site_url(), '301' );
exit;
}
}, 1001 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment