Make metabox of custom post type fully autosave- and bulk-/quick-edit compatible

WordPress does not send the content of custom fields during autosave (just title, slug and content). That’s why the custom field content will be deleted if you try to save the data: You cannot see the difference between deleted and missing content. I would create a separate autosave function for that, because the way WordPress … Read more

Adding content to a taxonomy metabox

From core: function post_tags_meta_box($post, $box) { $defaults = array(‘taxonomy’ => ‘post_tag’); if ( !isset($box[‘args’]) || !is_array($box[‘args’]) ) $args = array(); else $args = $box[‘args’]; extract( wp_parse_args($args, $defaults), EXTR_SKIP ); $tax_name = esc_attr($taxonomy); $taxonomy = get_taxonomy($taxonomy); $disabled = !current_user_can($taxonomy->cap->assign_terms) ? ‘disabled=”disabled”‘ : ”; $comma = _x( ‘,’, ‘tag delimiter’ ); ?> <div class=”tagsdiv” id=”<?php echo $tax_name; … Read more

dynamically add a custom field or metabox to custom post type [duplicate]

To add a metabox to a post type car use the proper hook: add_action( ‘add_meta_boxes_car’, ‘register_car_metabox’ ); function register_car_metabox() { add_meta_box( ‘car-data’, ‘Car data’, ‘car_metabox_callback’, NULL, ‘normal’, ‘default’ ); } The content will be created in your callback: function car_metabox_callback() { # get post meta and print input fields }

Add Standard Page Attributes Metabox for Page Parent

Although not listed in the following resources, seems that parent_id is a reserved name in $_POST and $_REQUEST: Function_Reference/register_taxonomy#Reserved_Terms List of reserved names in $_POST and $_REQUEST used by WordPress 3.5 This code works in a Woocommerce product page to show a dropdown of regular pages. Also, in your code, you were missing the get_post_meta … Read more

Better Method for Multiple Meta Boxes

I’ve sort of done this with using the same function to save the meta on the post screen and also on the quickedit. In your case I think you need to add an or clause to your nonce validation. if (!wp_verify_nonce($_POST[‘home_meta_box_nonce’], basename(__FILE__))) return; as if (!wp_verify_nonce($_POST[‘home_meta_box_nonce’], basename(__FILE__)) || !wp_verify_nonce($_POST[‘home_meta_box_left_nonce’], basename(__FILE__)) ) return; Then you could … Read more

Make the Status, Visibility, or Date fields opened by default in the Publish box

This jQuery code seems to work, when added via the admin_footer hook. #submitdiv = the whole Publish metabox .misc-pub-section = each UI section (except the Publish and Save sections) .hide-if-js = the fields that are hidden by default $(‘#submitdiv .misc-pub-section’) .has(“#post-status-display, #timestamp”) .find(‘.hide-if-js’) .toggle(); That will unhide the Status dropdown and the Date picker.

Custom Metabox Not Saving

When you do that include, you are trying to add the save_post hook inside the add_meta_boxes_$post_type hook. It should be independent. add_action( ‘add_meta_boxes_page’,’load_home_meta’ ); add_action( ‘save_post’, ‘save_home_meta’ ); // Declare all callback functions Also, you shouldn’t declare a function inside a function. Maybe you should consider creating a plugin for handling this, see: Where to … Read more