Store multiple textarea data in database from a metabox
Store multiple textarea data in database from a metabox
Store multiple textarea data in database from a metabox
You mentioned that you’ve added the meta box for pages: I have created a custom template, added two metaboxes in Pages using a ‘Page_Fiche_Metier.php’ template. However, in prfx_image_enqueue(), the code only runs if the post type is post. Changing prfx_image_enqueue() so that it checks for the page post type will fix the issue. function prfx_image_enqueue() … Read more
Get updated meta value after post update or published (custom post type) using hook
Handling admin notice on Edit Post When action related to post or editpost, we will be faced with redirect_post function. There are two filters you can use to handle the post messages, redirect_post_location and post_updated_messages ( see the list messages at https://core.trac.wordpress.org/browser/tags/4.8/src/wp-admin/edit-form-advanced.php#L135 ). Here the sample code how to handle the messages. Create new message … Read more
I’ve managed to make it work because of @howdy_mcGee’s comment. I did not notice that I had to call the specific post type name of it. my code is now like this and it shows up! function slide_add_post_meta_boxes() { add_meta_box( ‘pukkemukslideshow’, // Unique ID __( ‘Slideshow’, ‘example’ ), // Title ‘slide_post_class_meta_box’, // Callback function ‘slideshow’, … Read more
1) For escaping content of textarea you should use esc_textarea and not esc_attr. 2) You should not escape things when storing them in the DB, escaping should be done only at output time. (I assume that you can find an edge case in which it might be needed, but as a general rule, just don’t … Read more
You can use the do_meta_boxes hook to remove the metaboxes instead. Like below add_action( ‘do_meta_boxes’, ‘vpm_remove_meta_box’ ); function vpm_remove_meta_box() { remove_meta_box( ‘ortext-metabox’, ‘post’, ‘normal’ ); remove_meta_box( ‘ez-toc’, ‘post’, ‘normal’ ); } See this for more info https://developer.wordpress.org/reference/functions/remove_meta_box/
Metabox not show in categories custom post type cmb2
I had a similar problem with a custom metabox. The problem was the use of $post_id inside the save-function. Using global $post and then $post->ID solved the problem for me. function save_metabox(){ global $post; if(defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE){ return $post->ID; } $myData = $_POST[‘my data’]; update_post_meta($post->ID;, $myData); }
The $_POST[”] has to contain the name attribute of the input field and not the ID. So to modify your code: function silly_display_metabox( $post ) { wp_nonce_field( basename( __FILE__ ), ‘silly_extrnum_nonce’ ); ?> <label for=”sillyNum”>Silly Number</label> <input type=”number” id=”sillyNum” name=”sillyNum” placeholder=”Write a number…”> <?php } And function silly_save_metabox( $post_id ) { $is_autosave = wp_is_post_autosave( $post_id … Read more