Support » Everything else WordPress » including wp-blog-header.php in external php file

Viewing 12 replies - 1 through 12 (of 12 total)
  • Actually it’s the wp-config.php file.

    What do you mean by that?

    If you want to use wordpress functions in another PHP program, you need to do a <? php include_once(path/to/wordpress/wp-config.php) ?> that will load wordpress functions into whatever php program you want to use wordpress in. wp-blog-header.php is something else.

    Hmm… every Codex article and hundreds of forum topics always say to use wp-blog-header.





    uh no. You are absolutely wrong.

    the proper way to do it is to include wp-blog-header.php

    For instance, if the page you are trying to do this on resides in the same directory, you use:

    /* Don't remove this line. */

    rather than share the source of all the files Ive done this in .. ill just suggest you do some reading:

    Grab the header:

    In order to transform regular PHP pages into ones that utilize WordPress, you need to add either of the following code snippets to the start of each page.

    /* Short and sweet */
    define('WP_USE_THEMES', false);




    I will kill the dying horse by posting the content of wp-blog-header.php, the contents of which explain precisely why its the file that needs to be called:

    if (! isset($wp_did_header)):
    if ( !file_exists( dirname(__FILE__) . '/wp-config.php') ) {
    	if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false) $path = '';
    	else $path = 'wp-admin/';
    require_once( dirname(__FILE__) . '/wp-includes/classes.php');
    require_once( dirname(__FILE__) . '/wp-includes/functions.php');
    require_once( dirname(__FILE__) . '/wp-includes/plugin.php');
    wp_die("There doesn't seem to be a <code>wp-config.php</code> file.
    I need this before we can get started. Need more help? <a href=''>We got it</a>.
    You can <a href='{$path}setup-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.", "WordPress &rsaquo; Error");
    $wp_did_header = true;
    require_once( dirname(__FILE__) . '/wp-config.php');
    require_once(ABSPATH . WPINC . '/template-loader.php');

    Notice that in addition to to the other files, it loads the config file. It always has.

    I’m sorry everyone, I stand corrected. I was thinking of something completely different.




    no worries 🙂

    I kill dying horses, daily.

    I am getting this problem on my blog. Does anyone know what is going on?!

    Warning: main(/home/yahphoto/public_html/designerhacks/wp-admin/wp-includes/classes.php): failed to open stream: No such file or directory in /home/yahphoto/public_html/designerhacks/wp-admin/wp-blog-header.php on line 8

    Fatal error: main(): Failed opening required ‘/home/yahphoto/public_html/designerhacks/wp-admin/wp-includes/classes.php’ (include_path=’.:/usr/local/lib/php’) in /home/yahphoto/public_html/designerhacks/wp-admin/wp-blog-header.php on line 8

    ya. you must be missing the dot before the slash i.e. using “/mydirectory/” instead of “./mydirectory/”

    I’ve got exactly the same problem like phillipcc

    lynx http://site/ returns 200
    lynx http://site/index.php returns 200
    lynx http://site/another/index.php returns 200
    lynx http://site/another/ returns 404 but page displays

    Something is wrong with the last test, but what? Notice if I turn permalinks off all tests return 200.

    Is there a solution???

    Hahahah, the image of you killing some poor old dying horse…not nice. I think the phrase you were after is “flogging a dead horse”. I.e. doing something totally pointless as in whipping a deceased equine.


Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘including wp-blog-header.php in external php file’ is closed to new replies.