When I do something like this (in my plugin function inside WP admin):
$metaboxes = get_post_meta( $post_id );
echo "<pre>";
print_r($metaboxes);
echo "</pre>";
die();
I get all my metaboxes info except the datetime.
Why is that? Where are they stored and how can I access them?
I am using this plugin http://www.deluxeblogtips.com/meta-box/ to add custom meta fields to my content type like:
array(
'name' => 'Date and time:',
'type' => 'datetime',
'id' => "rw_datetime",
),
I want to save the datetime
field if some other field has certain value using save_post
function and this is not working for datetime for some reason:
update_post_meta($post_id, 'rw_datetime', '2013-08-28 11:11' );
But something like this for a text field is working nice:
update_post_meta($post_id, 'rw_some_textfield', 'This is working!' );
Why is that? Why it's not working for datetime and why it is working for other field types?
How can I grab the datetime value if I know the $post_id
and then update this field using update_post_meta()
function?
UPDATE:
Code of my save_post function:
add_action( 'save_post', 'things_before_save' );
function things_before_save( $post_id ) {
// No auto saves
if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
// make sure the current user can edit the post
if( ! current_user_can( 'edit_post' ) ) return;
// assure the post type
if ( ! get_post_type($post_id) == 'cards' ) return;
// working
update_post_meta($post_id, 'rw_some_textfield', 'This is working!' );
// not working ;(
update_post_meta($post_id, 'rw_datetime', '2013-08-28 11:11' );
}
Notice that I am not working with any variables, just with strings This is working!
and 2013-08-28 11:11
to eliminate possible errors.
So, I guess the problem is that rw_datetime is stored somewhere else and not at the same place as other metaboxes.