get_post_meta() in functions.php
-
I am adding a section to my theme’s post pages using add_meta_boxes. The value of the input is being saved to the postmeta table just fine when the page is initially saved or updated. However, after saving/updating the value of the text input just comes up blank.
I tried to use:
$desc = get_post_meta($post_id, 'sandbox_description', true); echo '<input type="text" id="myplugin_new_field" name="myplugin_new_field" value="' . $desc . '" size="30" />';
to retive the value of the custom field and output it back to the value attribute. It seems that $desc never gets set this way. Is there something wrong with the way I am trying to retrieve the custom field? Is this the proper way to do this?
Thanks.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘get_post_meta() in functions.php’ is closed to new replies.