Support » Plugins » cannot access $wpdb

  • Hello.

    I am not able to call $wpdb->prefix or seemingly any wp property from a plugin that I am creating. I have read a few things but they don’t seem to correspond with newer versions.

    Thanks for any comments

Viewing 2 replies - 1 through 2 (of 2 total)
  • Having the same problem here. I get errors as if the object didn’t exist.

    Okay, to everyone who encounters this same issue, please try including the file “wp-load.php” before globalizing $wpdb and making any reference to it.

    Like this, for instance, which worked for me:


    That’s a relative path, so change it according to your own particular scenario.

    Now, maybe I missed it, maybe it’s really not there, but it seems there are way too many people having this problem, so there has to be something failing with the documentation at the WordPress Codex.

    Anyway, including that file should help.

    I hope this solves it for you.


Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘cannot access $wpdb’ is closed to new replies.