external wordpress pages using wp-blog-header

All we need is an easy explanation of the problem, so here it is.

I am setting up a few sections of a website external to the core wordpress installation, but I still want to use the built in wpdb functions, and/or header files from wordpress.

I follow the instructions outlined in wordpress, setting up my headers:

 <?
 require('../cms/wp-blog-header.php');
 define('WP_USE_THEMES', false);    
 .
 . ?>

Everything works great. I can use wordpress’ built in functionality while extending my site to use other functionality.

In one case, the file is outside of my wordpress directory. In another case, the file is nested in a folder in the root of my wordpress directory.

However, when loading the page in question, I get a 404 in the Net Panel of my inspector of the exact page I’m loading, like WordPress can’t find the page, but since it’s a real php page, of course it loads. Most importantly, the pages fail to load using IE8.

Does anyone have insight to this issue?

Example Link

More links and screenshots available, but I don’t have enough reputation.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

consider including wp-load.php instead of wp-blog-header.php

You can also “force” a 200 response using status_header(200); although, depending on how you code your site, this could interfere with sending legitimate 404s.

Method 2

Solution Found! Thanks to these guys

require('../cms/wp-config.php');  
$wp->init();  
$wp->parse_request();  
$wp->query_posts();  
$wp->register_globals(); 

The key is, don’t use wp-blog-header, but this code instead.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply