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


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: