How to make portfolio archives not public and non searcheable

Hi I have used some code to make the changes successfully, excluding specific categories. It direct to the home page if user is trying to access any portfolio archive.
However, it blocks me on wordpress backend to access any of my portfolio entries, I can’t edit or access a list at all, it will redirect me to home page.
The second issue is that the entire shop is blocked too.
Could I ask for a proper solution to keep all portfolio entries and archives non searchable by crawlers?
This is the code I have used in functions.php

function redirect_to_home( $query ){
   if(is_archive() ) {
  wp_redirect( home_url() );
  exit;
  }
}
add_action( 'parse_query', 'redirect_to_home' ); 

My website is: https://idophotographydungarvan.ie
Thank you for your help.

Hello @pablo102

Thanks for writing to us.

It would require custom development to hide the portfolio archive page for non logged in users. I would suggest you consult a developer who can assist you to do the customization.

Please note that we do not provide custom code support since it is out of the support scope.

Have a great weekend!
Thanks for understanding

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.