cannot access $wpdb (3 posts)

  1. g_force
    Posted 5 years ago #


    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

  2. Arwym
    Posted 5 years ago #

    Having the same problem here. I get errors as if the object didn't exist.

  3. Arwym
    Posted 5 years ago #

    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.

    Reference: http://wordpress.org/support/topic/need-help-accessing-wpdb?replies=4

Topic Closed

This topic has been closed to new replies.

About this Topic