• I need to be able to load up wordpress and load up the theme, but i dont want to perform any queries against the WP database for posts. I have a custom php file that gets a post from a non WP database. I have setup the htaccess file to correctly route this. The top of the script loads wordpress.

    require_once('../../../wp-blog-header.php');

    From here i get the global $post object and populate it with the custom data that i want to display on the page. I also need to alter the response http code since calling wp-blog-header.php generates a 404 error since no post was found. I need to cut this part out, but still load up wordpress.

    After populating $post i call the theme to render the post using the wordpress theme.

    include get_template_directory()."/page.php";

    This is working fine in web browsers. I have fixed all issues and it renders great, but search engines and bots have trouble with it. For example, if the url of the page is mysite.com/something, wordpress checks for a post with a slug that contains this value. 90% of the time it doesnt find a post and generates a 404, which i am able to handle. 10% of the time it finds a similar slug. eg. “somethingelse” and performs a 301 redirect which is causing a lot of trouble.

    How can i load up wordpress and be able to call the theme without it querying the wordpress DB for a post?

  • The topic ‘Load wp-blog-header.php without starting the loop.’ is closed to new replies.