WordPress select query issue

One more for the pot: $wpdb->get_col can be used to return a “single dimensional” array of all values set for “sleeps” global $wpdb; $values = $wpdb->get_col( “SELECT meta_value FROM wp_postmeta WHERE meta_key = ‘sleeps'” ); echo implode(‘,’, array_unique($values) );

load post data into mysql

I’m not sure of having understood what you are asking for. But if my guess is correct, you can achieve this goal by using $wpdb global variable. But, in order to be more specific, I need to know how and when you want the database to update those informations.

Trouble migrating custom post types from non-wordpress cms

I was able to come up with a solution according to advice from the comments. Working code: function import_shows() { $olddb = new wpdb(constant(“DB_USER”),constant(“DB_PASSWORD”),”THE_DB”,constant(“DB_HOST”)); $sql = “SELECT * FROM shows”; $rows = $olddb->get_results($sql); foreach($rows as $obj) { error_log($obj->name); } return; }

OR condition not working

The problem is strictly with your query… or to be more precise, with your misunderstanding of your query 😉 You’ve put || in there and you assume it is OR operator, but… depending on configuration of server it can act as OR or… string concatenation 😉 So change it to OR and it should work … Read more

Deleting a table row through query

Actually wpdb delete function works with an array of data, so i just put two variables in and solved it. $wpdb->delete($mySqlTableName, array($idKey => $idVal, Status => “Cekanje”)); And solved.

‘posts’ table should not store the absolute image path

Well, after a little research I realized that it is an (inconvenient) feature of WordPress to store the absolute path of the images and other files, something that I completely disagree with. In any case, I discovered this plugin https://wordpress.org/plugins/root-relative-urls/. It does not fix the urls of files already inserted, but it corrects those of … Read more