• Resolved johnflufin

    (@johnflufin)


    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?

    • This topic was modified 7 years, 6 months ago by johnflufin.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support amboutwe

    (@amboutwe)

    Can you please submit that to our GitHub repository for Yoast SEO? Thanks!

    If you have not submitted an issue previously, this guide will help you submit a complete report which may result in a faster resolution.

    Thread Starter johnflufin

    (@johnflufin)

    Sure thing. On a semi-related note the “Read this *before* you post!” pinned post by Joost on your plugin support section links to a REALLY outdated forked version of WordPress SEO on GitHub. Otherwise I would have posted there already. Seems like that fork should be closed.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Breaks php include’ is closed to new replies.