Starting with tabbed metabox

First, you have to create the metabox. Then you have to add tabs to the metabox. For the first step, to create a metabox, here is a tutorial for you. You can use that as bases for your metabox, and maybe modify it according to your needs. For the second step, you have to add … Read more

How to use Gutenberg in CMB2?

This is, at least at the moment, not possible. You can use CMB2 Meta Boxes in Gutenberg Post Types, but you can not make a CMB2 Field where you can use Gutenberg – as of now. However, as the Gutenberg Editor is developed further, a CMB2 Block-Editor-Field is not that far. As of now, you … Read more

Add a metabox when editing a media – but only for images

gordie Here is an example of meta box for bellow possible mime types ‘image/jpeg’,’image/gif’,’image/png’,’image/bmp’,’image/tiff’,’image/x-icon’ //add meta_box for image mime types only function add_our_attachment_meta(){ $attachment_id = $_REQUEST[‘post’]; $attachment_mime_type = get_post_mime_type($attachment_id); $possible_mime_types = array(‘image/jpeg’,’image/gif’,’image/png’,’image/bmp’,’image/tiff’,’image/x-icon’); if(in_array($attachment_mime_type, $possible_mime_types)){ add_meta_box( ‘custom-attachment-meta-box’, ‘Attachment Extra Details’, ‘our_attachment_meta_box_callback’, ‘attachment’, ‘normal’, ‘low’); } } add_action( ‘admin_init’, ‘add_our_attachment_meta’ ); //callback function of custom metabox function … Read more

I have added a metabox and inside it i added a secondary title and a text editor but if i write anything it does not save it or show it on my page

You have used $post instead of $_POST in save function. That is why data is not saved. You have should use : $_POST[ ‘custom_meta2_nonce’ ] $_POST[‘sec_title’] $_POST[‘principle_duties’] instead of $POST[ ‘custom_meta2_nonce’ ] $POST[‘sec_title’] $POST[‘principle_duties’] Use below code to save data : function custom_meta2_save($post_id){ //checks save status $is_autosave = wp_is_post_autosave( $post_id); $is_revision = wp_is_post_revision( $post_id); $is_valid_nonce … Read more

save_post_{$post->post_type} action firing on second save

I think you’d have to move the check for whether or not the $location === header into the metabox then use the following to save the meta data. Like this: //In your metabox before the fields $location = get_post_meta( $post->ID, ‘_est_template_location’, true ); if( empty( $location ) || $location != ‘header’ ) : $location = … Read more

Display stored value in Meta Box

Firstly, you have to pass get_post_meta() field name in your input type name which you have to store user data value and if it’s not created then it will create in save_your_fields_metabox() function. public function news_settings_html($post){ global $post; $meta = get_post_meta($post->ID, ‘your_store_field_name’, true); <input type=”hidden” name=”your_meta_box_nonce” value=”<?php echo wp_create_nonce(basename(__FILE__)); ?>”> <input type=”text” value=”<?php if (is_array($meta) … Read more

HTML Table creator in metabox to put into post theme

This plugin adds many useful (and some less useful) to TinyMCE, table editor among them: http://wordpress.org/extend/plugins/tinymce-advanced/ It also gives you full control over what buttons are shown and where in the editor, so it might be good to install it in any case.

WordPress global variables?

Meta data is save in postmeta table and to get them you can use get_post_meta($post_id,’meta_key_name’,true); so in your shortcode function globilaize $post object and get you value like that if($something == “value”) { global $post; $one = get_post_meta($post->ID,’value_name’true); $two = get_post_meta($post->ID,’value2_name’true); }