Search code examples
phpwordpressrequirecustom-wordpress-pages

Require wp-load.php returns errors


I am trying use wordpress functions outside of wordpress by simply requiring wo-load.php into the header.php of the other website.

Example :

public_html/wp-load.php (main Wordpress directory) public_html/Other_WebSite_Folder/core/header.php

So inside header.php I have added this code:

require_once ($_SERVER['DOCUMENT_ROOT'].'/wp-load.php');

So theoretically it should work, but what happens is that I am getting this error :

Fatal error: require_once(): Failed opening required '/public_html/Other_WebSite_Folder/wp-includes/load.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /public_html/wp-load.php on line 4

As you can see, for some reason the require script trying to load wordpress files from the other website folder instead just of loading the functions that i need into it.

I done same sort of integration before and it was working just fine, I can't fiend the reason why this is keep happening right now ?


Solution

  • Try this :

    in public_html/Other_WebSite_Folder/core/header.php

    require_once ('../../wp-load.php');