This is the variable that interfaces with the backend of WordPress. It is used to add/delete/modify elements in the database used by WordPress.

It is an instance of the wpdb class defined in [wordpress root folder]/wp-includes/wp-db.php.

Plugin authors can use this variable to interface with the database. The database design is documented here.

Back to full list of global variables.

Technorati tags:

Discussion [Participate or Link]

  1. Abhijit Nadgouda @ iface » Wordpress Global Variables said:

    […] $wpdb […]

  2. Abhijit Nadgouda @ iface » Blog Archive » Of Wordpress Search said:

    […] However the plugin can use the wpdb variable to identify versions and use the inherent capability for version greater than 4.0.1 and David Altherr’s boolean search functions or Boolean Search Plugin by Beau Collins for the lower versions. […]

  3. Abhijit Nadgouda’s List of WordPress Global Variables « Lorelle on WordPress said:

    […] User Data: wp_roles, user_pass_md5, user_url, user_login, user_level, user_identity, user_email, user_ID, current_user, and wpdb […]

  4. Erica said:

    Can you give an example of how this would work with a cutosm query as well? I have two sites sharing a server but with separate DBs. I’d like to bring in the 3 latest posts from one DB (blog) into the 2nd. I’ve found a few examples online with this method but none of them seem to be working. Either I’m getting something wrong, or it’s not doing what I was hoping for.TIA!

Say your thought!

If you want to use HTML you can use these tags: <a>, <em>, <strong>, <abbr>, <code>, <blockquote>. Closing the tags will be appreciated as this site uses valid XHTML.



Abhijit Nadgouda
iface Consulting
+91 9819820312
My bookmarks


This is the weblog of Abhijit Nadgouda where he writes down his thoughts on software development and related topics. You are invited to subscribe to the feed to stay updated or check out more subscription options. Or you can choose to browse by one of the topics.