Leave a Reply

1 comment

  1. Very similar to this question of a couple of hours ago: How can I get a list of latest posts outside of my WP install?

    Use chdir() to move into WordPress root before including and even calling anything related to WordPress. The are cases where relative directory and file references are used, thus breaking many things.

    You can return to the previous directory afterwards by storing the get_cwd() first.

    $cwd = get_cwd();
    chdir( 'wordpress_root' );
    include 'wp-load.php';
    // ... do stuff with WordPress
    chdir( $cwd );
    // ... continue happily ever after
    

    Additionally, seeing that you’re working with session cookies, the paths for these cookies are invalid for the URI you’re working from. The browser will not send the WordPress authentication cookies that you have acquired previously since the domain roots are invalid and outside of the WordPress scope. You will need to alter the roots of these cookies from WordPress with something like this http://wordpress.org/extend/plugins/root-cookie/.