Can I query other databases from within WordPress using PHP/mySQL?

I have a site that is a mix of WordPress and other PHP pages. Can I query the other database and have the results show within WordPress?

Related posts

Leave a Reply

2 comments

  1. Late to the party, but if you’re willing to add stuff to the wp-includes/wp-db.php file you can query those other databases using the $wpdb object.

    Specifically, you need to add a var:

    /**
         * WordPress Term Relationships table
         *
         * @since 2.3.0
         * @access public
         * @var string
         */
         var $term_relationships;
    

    and add your database name to this:

    var $tables = array('users', 'usermeta', 'posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options','postmeta', 'terms', 'term_taxonomy', 'term_relationships');