For a particular project, I’m currently using only wp’s admin and core functions/sugars, so no themes. Still, I’m forced to choose a theme.
I would like a couple of things:
-
move theme’s functions.php (that currently contains only custom code by me) in /wp-contents, outside the themes and make WP still load it
-
force WP not to look for themes, so I can succefully delete the themes folder without getting an error in wp-admin
Is this possible? What’s the best way (without hacking the core)?
Point 2 is less crucial, since I can always hide the admin’s themes button. Point 1 is important.
For point 1, maybe I could load functions at the end of wp-config.php, or maybe (still in wp-config) I could hook at ‘init’ or ‘setup_theme’. Or maybe something else.. I’d like to know the best practice here.
thank you
I can’t see a reasons why you not just put your code from the
functions.php
into Plugins or Must Use Plugins, it isn’t that hard to do and is, in my mind preferable, to connecting this task somehow to thewp-config.php
.Besides that, if you don’t absolutely have to remove the backend/admin themes functionality itself, just remove, unset and/or make it inaccessible from the backend/admin area. Seems more practical to me, probably not knowing all the determining factors of course.
Edit: this is complementary to what @ravs suggested
Setting WP_USE_THEME to false inside of index.php in wordpress directory, can save some execution time by skipping the theme loading process.
This answer explains the process more.
Note:: But I think using the WP REST API may be a better route now a days.