I use wp-load() to load the basic WP environment and then read some info from the DB without any problem.
But now i need to render the full header for a page, including the Yoast SEO plugin. After calling wp-load() and getting my data from the DB, i call wp_head() to render the header, but the output is basically empty as the normal WP environment has not been loaded. How can load the WP environment to the point that all the plugins without any problems.
I did try various aproaches
- calling
wp('p=83');
to init the environment with the data of the correct page (ID = 83) - initializing the
$wp_query
and$post
vars manually with the same data they would get in a normal page call - trying to find more global data structs that are set in a normal call but not with wp_load
but no love.
EDIT:
So the exact situation is this:
/test.php
/wordpress/{all the wp stuff}
in my test.php I include the wp_load.php
require_once("wordpress/wp-load.php");
then i tried various versions, including the two solutions given by fischi,
- using wp_head directly in test.php
- using the get_header() directly in test.php
- placing it in a template file and call that via get_header('justthehead')
But nothing works!
My problem was not that i couldn't execute the wp_head() function, that was working from the beginning, but that apparently the wp_load is not enough for some plugins to work correctly.
In my case i try to get the Yoast SEO plugin to work, but it does not show me the same output as when called in 'the normal way' inside the template for page p=83.
So i DO get the wp_head output, but it is not complete as the data from the plugin is missing.