Вызов каталогов для загрузки в wordpress


У меня есть установка wordpress с двумя вложенными папками "активы" и "функции". Эти папки содержат важные файлы для темы wordpress.

Какой был бы лучший способ загрузить эти файлы Я пробовал что-то подобное, которые находятся в файле под названием constants.php в моем корневом каталоге

    define('CSS_DIR', get_stylesheet_directory() . '/');
    define('FUNCTIONS_DIR', get_stylesheet_directory() . '/');

Затем в моем functions.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
Author: dannyw24, 2014-02-13

1 answers

Обычно я также разделяю функции своей темы на несколько файлов и включаю их в свой functions.php, например:

// load helper functions
require_once get_stylesheet_directory().'/inc/helper-functions.php';

// load admin functions
if (is_admin())
    require_once get_stylesheet_directory().'/inc/admin-functions.php';

// load theme functions
require_once get_stylesheet_directory().'/inc/theme-functions.php';

// load post functions
require_once get_stylesheet_directory().'/inc/post-functions.php';

// load WooCommerce functions
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins'))))
    require_once get_stylesheet_directory().'/inc/woocommerce-functions.php';

Почему это не работает для вас?

Если вы говорите о объемном в том числе, вы можете взглянуть на glob и тому подобное...

 1
Author: tfrommen, 2014-02-13 14:40:14