Proper approach to moving complete site from one domain to another AND preserve widgets

There are some instances of serialized data in the database, notably in things like widget options, that become invalidated if you do a blind search-and-replace without accounting for different string lengths. You might try a tool like this one to do a search and replace that also handles serialized data: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

How to migrate a database from a server to another

The database user name/password is not stored in the database; it is only used to access the database. Change the username (and password, too) to the new values in wp-config.php. And the problem might be access to the database via phpmyadmin; check your username/password in Cpanel or some other hosting control panel.

pull data from a remote wordpress database

Ok. There are few things wrong here. query_posts isn’t mean to be used that way so don’t. Try the same code with $likes=new WP_Query(array(… instead. $likes=new WP_Query(array( ‘post_type’ => ‘post’, ‘ignore_sticky_posts’ => true, ‘filter_type’ => ‘user_liked’, ‘filter_user’ => $user_id )); That is problem one. Then even if $likes were set correctly you’d clobber it. $likes= … Read more

Custom $wpdb returns unexpected time based results

This may be your problem: $wpdb->terms.slug = ‘another-sample’ OR $wpdb->terms.slug = ‘sample’ AND //the date logic doesn’t seem to qork quite right $wpdb->posts.post_date > DATE_SUB( NOW(), INTERVAL 7 DAY)”; Your OR operator might be confusing the query. Try using parentheses: ($wpdb->terms.slug = ‘another-sample’ OR $wpdb->terms.slug = ‘sample’) AND //the date logic doesn’t seem to qork … Read more

Custom SQL query ORDER BY term_order

In your case you are referring ORDER BY {$wpdb->terms}.term_order and as default in wordpress wp_terms table don’t have this column the term_order column resides in the wp_term_relationships table and you are referring wp_terms table to ORDER BY this column which is not is present in that table instead of this you have to do something … Read more

How to use get_results() in widget front end?

It seems that you can’t access to it. Please try add global $wpdb; to your function. UPDATE For reference, in WordPress Codex you will find: WordPress provides a global variable, $wpdb, which is an instantiation of the class already set up to talk to the WordPress database. Always use the global $wpdb variable. (Remember to … Read more