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.
@peiqinglong,
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:
<?php
/* Don't remove this line. */
require('./wp-blog-header.php');
?>
rather than share the source of all the files Ive done this in .. ill just suggest you do some reading:
http://ww.wp.xz.cn/support/topic/96768?replies=5
http://ww.wp.xz.cn/support/topic/117418?replies=14
http://ww.wp.xz.cn/support/topic/86399?replies=41
http://codex.ww.wp.xz.cn/User:Jalenack/Integrating_Wordpress_into_an_Existing_Site
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.
<?php
/* Short and sweet */
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
?>
<?php
require('/the/path/to/your/wp-blog-header.php');
?>
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:
<?php
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='http://codex.ww.wp.xz.cn/Editing_wp-config.php'>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 › Error");
}
$wp_did_header = true;
require_once( dirname(__FILE__) . '/wp-config.php');
wp();
gzip_compression();
require_once(ABSPATH . WPINC . '/template-loader.php');
endif;
?>
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???
Cheers
Jo
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.
db