SQL query to change custom field in WordPress database

Recommend a database backup before you do this. ** updated the statement to specify “Y”, empty string, or null ** global $wpdb; $wpdb->query( “update {$wpdb->postmeta} SET meta_value=”X” WHERE meta_key = ‘old_price’ AND ( meta_value=”Y” OR meta_value=”” OR meta_value IS NULL ) );” );

Find locations of all featured images of draft posts via SQL

Alright this worked for me: First run the bellow script to generate the file locations of all files used for draft posts. SELECT voybp_posts.guid FROM voybp_posts WHERE voybp_posts.ID IN (SELECT voybp_postmeta.meta_value FROM voybp_postmeta WHERE voybp_postmeta.post_id IN ( SELECT voybp_posts.ID FROM voybp_posts WHERE voybp_posts.post_status=”draft”) AND voybp_postmeta.meta_key=”_thumbnail_id”) Export this as a CSV file and save it to … Read more

Store GravityForm data in phpmyadmin (mysql)

You can use something like below. Basically after form submission we get the data $entry extract the values we want (in the example $val1, $val2, $val3) then insert that data into the custom table with $wpdb: add_action(‘gform_after_submission’, ‘save_to_my_custom_table’, 10, 2); function save_to_my_custom_table($entry, $form) { global $wpdb; // update for your tablename (this assumes the table … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)