• This is on WP 2.7.1

    I was having issues where post meta data ws not updating and I finally narrowed it down to this simple test:

    update_post_meta(91, "mytest", $mytest);

    The $mytest variable = 1 (local variable)

    mytest key exists for post 91 and is currently set to zero (0)

    update_post_meta() is not doing the update with the local variable, however, if I change it to this:

    update_post_meta(91, "mytest", 1);

    …it works.

    I know $mytest = 1 because I put this line right below it:

    add_post_meta(91, "mytest2", $mytest, true);

    (mytest2 entry does not exist and is created by this line).

    So it fails to set mytest to 1, but DOES add a new record for mytest2 that is set to 1.

    Weird!

    Been trying to code around this, but anytime I stick a variable in there, add_post_meta doesn’t do the update, but when it’s a hard-coded number (constant), it DOES do the update.

    Anyone see this before or have any ideas?

    Thanks!

    John

  • The topic ‘update_post_meta Function Not Working 100%’ is closed to new replies.