How to store Gutenberg ColourPicker RGBA as metadata
How to store Gutenberg ColourPicker RGBA as metadata
How to store Gutenberg ColourPicker RGBA as metadata
From the OPs edit moved to an answer. I found an answer, also not a straight path, I’m sure there’s a better way to do this. basically I use a little helper method that queries the SQL with the meta_id and return the post_id: <?php function get_key_by_id( $meta_ids ) { global $wpdb; $meta_ids = absint( … Read more
When hooking the save_post action, you really need to isolate your operations so that every page/post/post_type save doesn’t try to add your post meta to the post. function foo_save(){ if(isset($_REQUEST[‘bar’) update_post_meta($_REQUEST[‘post_ID’], ‘bar’, $_REQUEST[‘bar’]); } add_action(‘save_post’, ‘foo_save’); The main issue with your code above is posts_numericalvalue needs quotes. Also, to use $post->ID you will need to … Read more
Think of them as array key/value pairs (kinda). These tables are used to store additional data about particular posts, comments, or users. The meta_key is the name by which the meta_value is retrieved, plus you have associations with particular posts, comments, or users by means of IDs. As far as structure goes, that is about … Read more
Figured it out where I had if ( ! empty( $cart_item[‘presc_data’] ) ) woocommerce_add_order_item_meta( $item_id, ‘Olho Direito’, $cart_item[‘presc_right_sphere’] ); I had to change to $data = $cart_item[‘presc_data’]; if ( ! empty( $cart_item[‘presc_data’] ) ) woocommerce_add_order_item_meta( $item_id, ‘Olho Direito’, $data[‘presc_right_sphere’] );
HTML in custom fields is, from my point of view, a weird use case of custom fields. Even more if the purpose of the used HTML is just look and feel (<strong> and <i> can be seen as just look and feel). It is really better if you use the HTML markup on the custom … Read more
Well, first use the hook properly. The post ID will be passed in. You don’t need $post->ID. Second, use the correct hook. If you want to run save_post only for your booking type, use save_post_booking But otherwise, the code works. I just ran a quick test. function booking_status_is_updated($post_id){ if(get_post_meta($post_id,’booking_status’,true)==’denied’){ delete_post_meta($post_id,’booking_slot’); } } add_action(‘save_post_booking’,’booking_status_is_updated’);
One of the Carbon Fields developers here. Thank you for your feedback! Currently, the Carbon Fields stores only the keys and they don’t have a built-in method to retrieve the selected values from the options array. You can pass a callable which returns an array with the options as an argument to the add_options method. … Read more
If that is all of your code, you’re missing a save_post action to save the data. Refer to the code sample provided on add_meta_box. add_action( ‘save_post’, ‘save_my_meta_box_data’ ); function save_my_meta_box_data( $post_id ){ // make sure it’s not an autosave if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return; // verify your nonce if ( !wp_verify_nonce( … Read more
Correct processing of `$_POST`, following WordPress Coding Standards