Support » Plugins » Best way to call WPDB object from a plugin

  • Any developers out there know a good way to access the WPDB object from within a plugin? I have a plugin that needs to be able to call WPDB in order to feed its management form some information. Any help would be appreciated.

Viewing 1 replies (of 1 total)
  • The “normal” way to do this is to simply declare access to the global instance of the object, which already exists in the WP environment:

    global $wpdb;

    Then just reference it the normal way like $wp->posts or $wpdb->comments, etc.

Viewing 1 replies (of 1 total)
  • The topic ‘Best way to call WPDB object from a plugin’ is closed to new replies.