Best way to call WPDB object from a plugin (2 posts)

  1. MikeRT
    Posted 10 years ago #

    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.

  2. Pizdin Dim
    Posted 10 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic