404 error but file displays in browser ok

I posted last night getting some help with a 500 error on a PHP script used by AJAX on my site. With some help I found the 500 was springing from the include (DOCUMENT_ROOT wasn’t serving the expected path, hence the 500).

Now this issue is fixed I’ve moved straight into the next one 🙁 Can anyone tell me why the following file shows the correct code in the Firebug output response, but springs a 404 in the console and fails to feed my AJAX script?

Read More
<?php
include($_SERVER['DOCUMENT_ROOT'] . '/sac-active-wp/wp-blog-header.php');

$pagetitle = $_POST;
$value = array_shift($pagetitle);

$thequery = 'title_li=&parent='.$value.'&sort_column=post_date&sort_order=ASC'; 
$display = wp_list_pages($thequery);
echo $display;
?>

As ever, thanks in advance folks. Help’s always appreciated!
Graham

Related posts

Leave a Reply

1 comment

  1. Resolved the issue myself! Should anyone else encounter a similar issue here’s the cause and solution:

    404 error sprang because I called in the WordPress header to allow plugin style development externally. The header included is incorrect, hence the 404. To remedy this, simply replace the include line with the following:

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

    This bypasses the 404 without the header hackfixes sometimes found (they’re not ideal for SEO!)

    Hope this helps somebody along the way 🙂

    Thanks,
    Graham