[resolved] 302 ajax including wp-settings.php (3 posts)

  1. bitxl
    Posted 2 years ago #

    I'm using ajax to run a script in a server with the purpose of retrieving some post information.

    I'm including WordPress in the regular way:

    define('WP_USE_THEMES', false);

    However, this gives a 302 moved temporarily as I can see in my console!

    If I prevent wp-settings.php from being included in wp-config.php it does get a regular response however I don't have functionality without it... Does anyone know what this could be? Are there files in wp-settings.php that are included that could give such an error?

  2. bcworkz
    Posted 2 years ago #

    Not sure it'll make any difference, but try requiring wp-load.php instead of wp-blog-header.php. It is after all what all the core files do that need to do such things.

    Alternately, run your request through wp-admin/admin-ajax.php with an action: value as part of the request data. Then hook the appropriate action to execute your script.

  3. bitxl
    Posted 2 years ago #

    thanks for the reply!

    wp-load didn't do what I wanted either, it somehow still lacked some functionality. Eventually I tried running the script from the wp-contents folder, not through ajax but a seperate file, turned out that some functions from the custom theme were declared twice and thus led to a php error, somehow WP made a 302 of that, still don't know how ;)

    I finally got it working however by changing directory and commenting out the useless functions :)

Topic Closed

This topic has been closed to new replies.

About this Topic