The value is not updated when using the following code:

add_action( 'save_post', 'updatethumb' );

function updatethumb( $post_id ) {

    //verify post is not a revision
    if ( !wp_is_post_revision( $post_id ) ) {

        //$thumb = get_post_meta(get_the_ID(), 'thumb', false);
        $ft=get_post_meta(get_the_ID(), 'thumb', true);
        //echo '<script>alert("'.$ft.'")</script>';
        update_post_meta(get_the_ID(), 'thumb', 'testxxx'); 



Why is that?

  • 1
    Why do you do this? get_the_ID does only work (as expected) within the Loop. You already have the post ID given in $post_id...
    – tfrommen
    Commented Apr 22, 2013 at 17:14

1 Answer 1


I'm not quite sure about what you want to do...
Maybe it's this:

add_action('save_post', 'update_thumb');

function update_thumb($post_id) {

    //verify post is not a revision
    if (! wp_is_post_revision($post_id)) {

        $new_value = 'testxxx';
        update_post_meta($post_id, 'thumb', $new_value); 



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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