我有一个wordpress安装,有两个子文件夹“assets”和“functions”。这些文件夹包含wordpress主题的重要文件。
加载这些文件的最佳方式是什么?我已经尝试过这样的方法,它位于一个名为常量的文件中。我的根目录中的php
define(\'CSS_DIR\', get_stylesheet_directory() . \'/\');
define(\'FUNCTIONS_DIR\', get_stylesheet_directory() . \'/\');
然后在我的函数中。我得到的php文件require_once(FUNCTIONS_DIR . \'functions/news.php\');
希望这是我想要实现的目标。
已更新,但有错误
我似乎有以下错误。
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