I have a wordpress install, with two sub folders “assets” and “functions” these folders contain important files for the wordpress theme.
What would be the best way to load these files I’ve tried something like this which live in a file called constants.php in my root directory
define('CSS_DIR', get_stylesheet_directory() . '/');
define('FUNCTIONS_DIR', get_stylesheet_directory() . '/');
then in my functions.php file i’ve got
require_once(FUNCTIONS_DIR . 'functions/news.php');
Hope this is clear what I’m trying to achieve.
updated with errors
I seem to be getting the following errors.
Warning: require_once(FUNCTIONS_DIR/functions/news.php): failed to open stream: No such file or directory in /home/foxyrent/public_html/wp-content/themes/foxyrental/functions.php on line 21
Fatal error: require_once(): Failed opening required 'FUNCTIONS_DIR/functions/news.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/foxyrent/public_html/wp-content/themes/foxyrental/functions.php on line 21
I usually split my theme’s functions into several files as well, and include those in my
functions.php
, like so:Why isn’t this working for you?
If you are talking about bulk including, you might have a look at
glob
and the like…