For security reasons, may I clarify with you if I can add the code to the functions.php file in order to protect the custom wordpress login page? If so, why did I get the error message? What is going wrong? Should I just replace the custom login file name, right?
Sure, you can do that. There are plenty of security plugins that can do this, but you’re free to create your own if you want.
I’m assuming you’re referring to the functions.php file of your custom plugin, right? Not a WordPress core file? Because hacking the WordPress core code is not a good idea, because it will be wiped if you upgrade.
As for why the code crashes, please make sure your code is valid. I’m not sure what you actually put in your site, but the code you shared uses ‘ to quote strings, but that curved quote is not a valid code character. You can use single quotes (') or double quotes ("), but not the character you used.
But please learn how to debug your WordPress code yourself. Writing some code, deploying it, see if it works, and then asking us to fix it if it doesn’t is not the way to create a plugin. You should be able to troubleshoot issues on your own first.
Take note it will get over-written with every WordPress update. Not advisable
as it is not best practice in the first place. You cannot find it because it is in your theme folder.
I would think the best way to package your extra functionality is as a plugin. Plugins are the way you can extend WordPress functionality without having to modify the WordPress core code.
I get that you want to reduce the number of plugins, but if you’re making a very simple plugin yourself, the overhead of the plugin system itself should be negligible.
After adjusting the code as per Admin’s suggestion, I can successfully change the Custom Login URL.
KangJL, I used the WordPress Theme is called “TwentyTwentyThree” which didn’t provide functions.php file in wp-contents>theme. That’s why I used the function.php file in wp-include. Moreover, I tried to add the code to another theme that has functions.php file in wp-contents>theme. Both websites didn’t show error messages.
I really appreciate you spending your valuable time and providing your professional advice on my issue.