Include files in functions.php

Including a file inside a subdirectory is the same as any other as long as you know the path to the file. Since it’s possible to move the ‘wp-content’ directory, don’t pass that part of the path to the require statement; instead, use the WP_CONTENT_DIR constant.

require_once WP_CONTENT_DIR . '/new-directory/my-file.php';

Also, you can leave out the parentheses since include and require are statements, not functions.

Leave a Comment