Breaks php include
-
My custom theme has a config.php file that I add to header.php via php include. Since header.php and config.php reside in the same theme directory I use
<?php include("config.php") ?>
at the top of header.php. This has worked flawlessly for many years. But the latest WordPress SEO seems to break the php include causing the config.php file to not load. No error. Just nothing.If I change the include to a fake path such as “abc/config.php” it returns the following errors
- Warning: include(/myabsolutepath/wp-content/themes/mytheme/abc/config.php): failed to open stream: No such file or directory in /myabsolutepath/wp-content/themes/mytheme/header.php on line 2
- Warning: include(): Failed opening ‘/myabsolutepath/wp-content/themes/mytheme/abc/config.php’ for inclusion (include_path=’/myabsolutepath/wp-content/plugins/wordpress-seo/vendor/yoast/api-libs/google:.:/usr/lib/php:/usr/local/lib/php’) in /myabsolutepath/wp-content/themes/mytheme/header.php on line 2
Especially note the second error. Looks like maybe WordPress SEO is doing some sort of intercept to add it’s contributions?
Since
include("config.php")
doesn’t return an error I assume that the file is found but it’s contents are not included for some reason.I fixed it by changing the include to use an absolute path
include(get_template_directory() . "/config.php");
but seems strange to me that this is necessary.Any idea what’s going on here?
- The topic ‘Breaks php include’ is closed to new replies.