Custom Meta Box returns no HTML

Try adding array( $this, ‘myskills_html’ ) to the third argument. public function skillsmetabox_init() { add_meta_box( ‘myskills_meta’, ‘Proficiency’, array( $this, ‘myskills_html’ ) ); } Since this is class method, it should have the $this as well. The same way you did with add_action( ‘save_post’, array( $this, ‘save_metabox_details’ ) );

Custom Meta Box (SELECT2) Not Saving Taxonomy Terms

First of all you saved the the terms value in a post meta table and not following the wordpress conventional method. To make it connect with default category with that post you need to modify your save_post action. Check the modified code. add_action( ‘save_post’, ‘rudr_save_metaboxdata’, 10, 2 ); function rudr_save_metaboxdata( $post_id, $post ) { if … Read more

Values entered in a meta box aren’t saved

You have to remove if($post_slug != $post->post_type){} from save function or change $post_slug = “book”; to $post_slug = “page”;. because it check $post slug is book or not. currently post type is page for contact us page. and you have set as book add_action(“save_post” , “wpl_owt_save_metabox_data” , 10 , 2); function wpl_owt_save_metabox_data($post_id, $post){ //verify nonce … 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

$post->ID not working in combination with a custom query

That $query->have_posts() modifies the global $post variable which is also used on the admin side, and on the front-end/public side of the site, you would simply call wp_reset_postdata() to restore the global $post back to the post before you call the $query->have_posts(). But on the admin side, you need to manually restore the variable like … Read more