I am connecting to another Wordpress instance (using same database but different table prefix) from my main Wordpress site. My main wordpress site has WPML plugin activated but second site has not. I am using following code:

            global $wpdb;
            $wpdb_backup = $wpdb;
            $wpdb = new wpdb('xxx','yyy','zzz','localhost');

            $args = array(
               'post_type' => 'post',
               'posts_per_page' => 3,
               'post_status' => 'publish',
               'orderby' => 'date',
               'order' => 'DESC',

            $query = new WP_Query($args);

            if($query->have_posts()) { 
                while($query->have_posts()) {

                   // do stuff here

            $wpdb = $wpdb_backup;

The problem is that new connection is not looking directly to blog_posts table but is trying to find post through WPML table causing this problem:

WordPress database error: [Table 'd54525_720.blog_icl_translations' doesn't exist]

Is there any way to disable WPML and enable it after query or change WP query to ignore WPML functions? Thanks for help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.