0

I've wrote some custom SQL queries inside a class method and noticed they seem to work if I hook the method to the wp action. If I hook to the plugins_loaded action, they don't seem to work.

My question:

At what point during a typical request does the $wpdb object become available?

Refs:

0

Please, post your code because the problem is not the one you guessed.

Actually, $wpdb is available very early: it is inited by the function require_wp_db() located in the file wp_settings.php at line #79.

The hook 'plugins_loaded' is fired in the same wp_settings.php file, but at line #237, so pretty after $wpdb is available.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.