[ad_1]
How to protect wordpress pages only viewed by logged users.? Don’t want to use plugin or password protect. Thought about a simple short code to protect login, but when placed in functions.php, it just disappears with theme update. Perhaps any other simple way?
​
​
[ad_2]
If it disappears from functions.php on theme update, you are probably using a prebuilt theme and not using a child theme for it.
You have to create a child theme, even if it’s only for the functions.php. More Info here: https://developer.wordpress.org/themes/advanced-topics/child-themes/
For your specific question, you can read how to redirect specific pages to e.g. Home, if the user is not logged in here:
https://wordpress.stackexchange.com/questions/131879/how-to-redirect-non-logged-in-users-to-a-specific-page