admin管理员组

文章数量:1328001

I have a child theme folder called themes/child-theme and inside I have a file dashboard_payments.php. Under the child theme folder I'm creating a new folder called gateway and inside there's a config.php.

So, how do I do a require_once inside dashboard_payments.php to call the file gateway/config.php? How would the require_once or include line look like?

I have a child theme folder called themes/child-theme and inside I have a file dashboard_payments.php. Under the child theme folder I'm creating a new folder called gateway and inside there's a config.php.

So, how do I do a require_once inside dashboard_payments.php to call the file gateway/config.php? How would the require_once or include line look like?

Share Improve this question asked Jul 18, 2020 at 22:30 cilapo1541cilapo1541 134 bronze badges 1
  • Why would you need to do this? – Jeff W Commented Jul 19, 2020 at 4:12
Add a comment  | 

2 Answers 2

Reset to default 1

Since 4.7 get_theme_file_path() is the right function to use:

require_once get_theme_file_path( 'gateway/config.php' );

You can use either

require_once(get_stylesheet_directory() . '/gateway/config.php');

or (should be faster)

require_once(__DIR__ . '/gateway/config.php');

本文标签: phpHow to specify the path for requireonce in a child theme