Sometimes we need to call wordpress functions outside of wordpress in a situation when we want to use them as they are. This will minimize our work to built custom functions to use outside environment and make our work easy.

Best way is :

<?php
require_once( '../wordpress_root_directory/wp-blog-header.php' ) //put correct absolute path for this file
get_header();

/* Use other wordpress functions here as per your choice */

get_footer();
?>

As we know when we view wordpress page, index.php called first. Look at our index template which is having below mentioned code :

<?php
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );

Look at the code above it is using wp-blog-header.php file and when we look in to this file we find wp-load.php as well. Complete code of wp-blog-header.php is :

<?php
/**
 * Loads the WordPress environment and template.
 *
 * @package WordPress
 */

if ( !isset($wp_did_header) ) {

	$wp_did_header = true;

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

	wp();

	require_once( ABSPATH . WPINC . '/template-loader.php' );

}

So, ultimately this process is using wp-load.php file which establish a bridge to use wordpress functions outside. This process will also make our work happen, but if we use wp-blog-header.php in spite of using wp-load.php file, our work will be appropriate in following ways :

1. This will load complete wordpress environment.
2. We can use wordpress hooks and actions
3. This will alos load wp() which is responsible to setup wordpress query

So, from both the process : including wp-load.php file or including wp-blog-header.php file, the process of using wp.blog-header.php is more appropriate approach.

Choice is yours 🙂