You are looking for the function get_header()
.
wp_head()
is the internal function of WordPress for doing things inside the head section (listing scripts, styles, metadata etc.).
The real HTML output comes from the function get_header()
, which includes your theme’s header.php
.
I suppose that you do not really want just this part of the header, as it leaves a lot of tags open, so my suggestion would be to create a file in your theme folder: header-justthehead.php
You can the call this file with a simple line:
get_header( 'justthehead' );
and you are in full control of the output for your custom header, and you do not have to mess with the header of your website itself. The only thing you still have to take care of, is that the right post is loaded. Define the $args
for your query_posts()
, and this should work for you. Never forget the wp_reset_query()
– even if you do not need it in this case.
include( 'wp-load.php' ); // loads WordPress Environment
query_posts( $args ); // load your desired Post/Page
if ( have_posts() ) : while ( have_posts() ) : the_post(); // Setup the Post/Page
get_header( 'justthehead' ); // Get your custom header-justthehead.php, containing your wp_head() call
endwhile; endif; // quit the loop
wp_reset_query(); // clean it up