Early page redirect

I added a redirection function that slows down my site. Where and how early can I add this action to reduce page load time?

Here’s code:

add_action( 'template_redirect', 'my_page_template_redirect' );
function my_page_template_redirect()
   if ( !is_user_logged_in() && !is_page(100)) {
     wp_redirect( '/?page_id=100/');

Read more here: Early page redirect

Leave a Reply

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