Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom post type Events.

Under Events, I have a custom meta box which selects the time and data of the event:

<?php
$meta_boxes[] = array(
'id'         => 'event_date_option',
'title'      => __('Event date'),
'pages'      => 'events',
'context'    => 'normal',
'priority'   => 'high',
'show_names' => true,
'fields'     => array(
    array(
        'name' => __('Event Date'),
        'desc' => __('When will the event happen'),
        'id'   => '_event_date',
        'type' => 'text_date',
    ),
    array(
        'name' => __('Event Time'),
        'desc' => __('What time will the event start'),
        'id'   => '_event_time',
        'type' => 'text_time',
    ),
),
);
?>

How can I save the date and time in a different table in my WP database when the admin clicks "Publish" or "Update"?

share|improve this question

1 Answer 1

As you can read in the WordPress Codex, you have to write your own save function for any meta box anyways. So instead of saving those values with a function like update_post_meta(), you could simply implement your own saving function using another table. But you also have to write a corresponding load function, as the using get_post_meta() function in the meta box render callback will not work for obvious reasons.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.