meta data not posting as expected
-
I’m writing what I think is a simple plugin designed to collect data about sermons posted and then display those posts slightly differently than regular posts. I’m hoping for a plugin so make it easy to share with a few other people who want to do the same thing but are too inexperienced (ie scared/intimidated) to create their own custom fields.
The problem is that the information collected in the metabox isn’t showing up in the post, and doesn’t seem to be appearing in the get_post_custom() array.
I’ve tested and the plugin is reading the metabox form correctly (ie getting the right info from the form) and something is being put into the meta, but it looks like consecutive numbers.
Here’s part of the function I’m using to save the meta info (validation removed for brevity):
function save_sermon_servant_info() { global $post, $sermon_servant_info; foreach ($sermon_servant_info AS $info) { if (){} //verification code goes here else { //verified //get data $field_data_name = $info['name'].'_value'; $sermon_servant_field_data = $_POST[$field_data_name]; if (! add_post_meta($post->ID, $field_data_name, $sermon_servant_field_data, true)) { update_post_meta($post->ID, $field_data_name['name'], $sermon_servant_field_data); } } }
And here is the results of putting
print_r(get_post_custom_keys($post_id));
into the coed for writing the post:
Array ( [0] => _edit_last [1] => _edit_lock [2] => _encloseme )And here is the results of this code in the post:
$sermon_info = get_post_custom($post_id); print_r($sermon_info);
Array ( [_edit_last] => Array ( [0] => 1 ) [_edit_lock] => Array ( [0] => 1232729875 ) [_encloseme] => Array ( [0] => 1 [1] => 1 ) )
And after the second time I try to reenter info into the meta fields this is how the array grows:
Array ( [_edit_last] => Array ( [0] => 1 ) [_edit_lock] => Array ( [0] => 1232730051 ) [_encloseme] => Array ( [0] => 1 [1] => 1 [2] => 1 ) )I’m having trouble interpreting this array, and there is precious little information in the codex about these keys. You can download the entire file: amosglenn.com/files/sermonservant.php
Where’s my data going?
Thanks for your help.
- The topic ‘meta data not posting as expected’ is closed to new replies.