SQL query to change the value of a Custom Field
If you’re looking for raw SQL query, then this should help: UPDATE <PREFIX>postmeta SET meta_value=”temp4″ WHERE meta_value=”temp1″ AND meta_key = ‘post_template’ If you want to run this query from WP, then you can use this: global $wpdb; $wpdb->update( “{$wpdb->prefix}postmeta”, array( ‘meta_value’ => ‘temp4’ ), array( ‘meta_key’ => ‘post_template’, ‘meta_value’ => ‘temp1’ ) );