Don’t forget to exit()
on redirect.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /** * This example redirects everything to the index.php page * You can do the same for the dashboard with admin_url( '/' ); * Or simply base the redirect on conditionals like * is_*() functions, current_user_can( 'capability' ), globals, get_current_screen()... * * @return void */ function wpse12535_redirect_sample() { exit( wp_redirect( home_url( '/' ) ) ); } add_action( 'template_redirect', 'wpse12535_redirect_sample' ); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.