Metabox doesn’t retain values

Many of the comments below refer to code used for debugging, which for clarity I’ve removed. I should have spotted this soon – you are adding only one row into the postmeta table, and that row has the key _my_meta. Before inserting the array int the table, WordPress serializes the array. When you retrieve the … Read more

Setting Event to Expire Using Custom Metabox

Have a look at the Post Expirator plugin. The Post Expirator plugin allows the user to set expiration dates for both posts and pages. There is a configuration option page in the plugins area that will allow you to seperataly control whether or not posts/pages are either deleted or changed to draft status.

Attaching a metabox to a single post

Since you are familiar with the how to create metabox using add_meta_box already, I’ll skip to the relevant bits. You can either conditionally add_meta_box depending on the current post title, or ID, (this is the preferred method) or, you can conditionally remove_meta_box depending on the the post displayed. To detect the current post ID you … Read more

Form submit from modal window to parent window

Use the parent method to pass data back to your meta field. Create a JS function to handle the passing of data from Thickbox to the meta field: function foo_interstitial(data){ $(‘.form-field-selector’).val(data); } Add a submit handler to your thickbox instance that passes to the parent.foo_interstitial() function. $(‘.thickbox-submit-selector’).submit(function(){ var _value_to_pass = $(‘.field-to-pass-selector’).val(); parent.foo_interstitial(_value_to_pass); });

How to create metabox that can be queried in the database?

As Kaiser suggested, the Metabox script available over at http://www.deluxeblogtips.com/2011/03/meta-box-script-update-v30.html propagates metadata to the database as individual entries instead of a serialized array. I suppose it is ultimately a matter of preference between how you want your data to be stored in the database. I have appreciated using Dimas’WP Alchemy plugin up until now, but … Read more

Change Default Custom Fields Metabox Name on cctm plugin

Try using this example from the WordPress Codex: add_action( ‘add_meta_boxes’, ‘myplugin_add_custom_box’ ); function myplugin_add_custom_box() { add_meta_box( ‘myplugin_sectionid’, __( ‘My Post Section Title’, ‘myplugin_textdomain’ ), ‘myplugin_inner_custom_box’, ‘post’ ); }

Metaboxes not saving data

There were three issues: The first wasn’t visible in the code presented. a wp_register_styles call was put into the constructor, which caused errors and somehow prevented saving post metadata. Second, the date field was a HTML5 date field, which conflisted with jQuery’s datepicker. Changing it to a text field fixed that. Third, the final if … Read more