Insert into the Database
INSERT INTO `flowerhhsa_wpbf4c`.`wp_postmeta` (`meta_id`, `post_id`, `meta_key`, `meta_value`) VALUES ('', '', 'xxxdate20180601', 1000);
Just match the fields. eg: (‘meta_id’,`post_id`) values (‘meta_id’,`post_id`)
In this case the meta_id and post_id are left blank as they get auto set in the database
Delete rows from the Database Where meta_key equals ‘meta_key_name’
DELETE FROM `flowerhhsa_wpbf4c`.`wp_postmeta` WHERE `meta_key`='xxxdate20180601';
Overwrite meta_key with New meta_key
UPDATE `flowerhhsa_wpbf4c`.`wp_postmeta` SET `meta_key`='key_name' WHERE `meta_key`='other_key_name';
MYSQL Select wordpress post by ID
SELECT * FROM flowerhhsa_wpbf4c.wp_postmeta where post_id = 413;
Add Custom Data to Woocommerce Order
add_action('woocommerce_checkout_update_order_meta',function( $order_id, $posted ) {
$order = wc_get_order( $order_id );
$order->update_meta_data( 'selected_date', $_COOKIE['selected_date'] );
$order->save();
} , 10, 2);
On Checkout the Custom fields will get added.
© Garth Baker 2025 All rights reserved.