I have been working on this for hours already but cannot manage to find a solution.

I am using this code to save a value for a metabox:

$fecha_proxima_revision = sanitize_text_field($_POST['fecha_proxima_revision']);
var_dump(update_post_meta($post_id, 'fecha_proxima_revision', $fecha_proxima_revision));
echo 'Post ID: '.$post_id.' - Value: '.$fecha_proxima_revision;

The output shows that the data is actually correct:

enter image description here

But in the database the value will not change:

enter image description here

It is a very strange case because I have worked with metaboxes a million times, but today it's like that value does not want to be saved into the database.

Also if I manually run update_post_meta($post_id, 'fecha_proxima_revision', 'whatever') it won't be updated.

I did not do add_post_meta with unique set to true. Never. This is the only line that has ever been used with that meta key.

The context, to see where $post_id comes from:

function seguimiento_planes_guardar_metaboxes($post_id, $post){

// Pero no si es un autosave
    return $post_id;

// Cancelar si el usuario no tiene permisos para editar
if(!current_user_can('edit_post', $post_id)){
    return $post_id;



add_action('save_post', 'seguimiento_planes_guardar_metaboxes', 1, 2);

What can I do to debug this issue?

  • 1
    Your code uses fecha_proxima_revision as the meta key, but the screenshot from your database shows fecha_proxima_renovacion. Are you sure you're looking for the right item when you're checking the DB?
    – Pat J
    Mar 8 '21 at 2:57
  • Also, where does $post_id come from? Mar 8 '21 at 3:01
  • @PatJ Thanks a lot for your kind attention. Actually I am updating two meta boxes and the same is happening for both. But to try to keep it simple I just attached one of them and did it wrong. Sorry and thanks again for your help. Mar 8 '21 at 3:10
  • @JacobPeattie Thanks for your attention, I updated the question with the context in which $post_id is defined. Mar 8 '21 at 3:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.