Can I use $wpdb for my custom tables in the WordPress database?

Yes you can. Straight from the codex

The $wpdb object is not limited to the default tables created by WordPress; it can be used to read data from any table in the WordPress database (such as custom plugin tables). For example to SELECT some information from a custom table called “mytable”, you can do the following.

$myrows = $wpdb->get_results( "SELECT id, name FROM mytable" );

Leave a Comment