Created
October 7, 2018 22:19
-
-
Save alanef/045d34364521ea1f9cae2d2653f0d8ae to your computer and use it in GitHub Desktop.
Redirect All Pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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