0
votes

I am trying to save some simple meta data on a per page basis, but have discovered that the update_post_meta is not seeming to actually save.

I have tried to run this simple test case, then check the actual database (wp_postmeta table) to see if it works:

update_post_meta( $post_id, 'parallax_test','true'); //Echoing out $post_id does give me a correct post id

When I then query the database, nothing shows up. I am completely stumped as the codex and other tutorials show that I am using the update_post_meta function correctly. And yes, this function is being called as a simple echo/die test before and after it work fine.

*Side note - I am able to save/retrieve meta data just fine using the 'custom fields' box in the admin. However, I need to be able to use my own meta box and data.

Any ideas?

2

2 Answers

0
votes

Try

global $post;

/* Your Codes Here*/

update_post_meta( $post->ID, 'parallax_test','true');
0
votes

Ok so it turned out to be a typo on my part. In another function I had accidentally used:

$post-ID

instead of

$post->ID

Oops...