I'm having a strange problem with same code not working on localhost vs production server.
The code is simple and I am trying to save a custom post type, but none of the data in my metaboxes are saved. I have some echo
statements in my save_custom_type
for debugging to see how the data looks like. Not even those print statements are echoed when I press "Publish" on production environment.
The custom post type is created in my theme, I hook into the action 'init'.
Code for creation and first lines up to the first echo statement in the save method.
function create_omgang_post_type() {
$labels = array(
'name' => 'Omgång',
'add_new' => 'Lägg till ny omgång',
'add_new_item' => 'Lägg till ny omgång',
'not_found' => 'Inga omgångar inlagda'
);
$args = array(
'description' => 'En omgång för denna säsong',
'public' => true,
'hierarchical' => true,
'show_in_menu' => false,
'show_in_admin_bar' => true,
'label'=>'Omgångar',
'labels' => $labels,
'supports' => array(
'title', 'page-attributes')
);
register_post_type('omgang', $args);
}
add_action('init', 'create_omgang_post_type');
/*-------------------------------------*/
function save_custom_post_omgang($post_id) {
$slug = 'omgang';
$post = get_post($post_id);
if($post->post_type == "omgang" ) {
if(! $_POST)
return;
if(!wp_post_revision_title($post_id)) {
$lag = get_all_lag();
$data = array();
foreach($_POST as $key => $value) {
//key#type
$explodedID = explode('#', $key);
if($explodedID[0] != $key) {
$key = $explodedID[0];
$type = $explodedID[1];
$data[$key][$type] = $value;
}
}
print_r($data); //this line is not even printed in PRD
}
}
}