Custom Meta Box Causing Error: "Are you sure you want to do this? Please
try again."
My custom post type have a meta box that is listing another custom post
types in its meta box. And it is causing error each time I try to publish
a post with that custom post type. It is always bring to a page that say
"Are You Sure You Want To Do This? Please Try Again". It does not have any
problem in my localhost, but does not work when I run it on my web
hosting.
Here is the codes:
add_action( 'add_meta_boxes', 'ind_pricing_tables_boxes' );
function ind_pricing_tables_boxes() {
$screens = array( 'indtable' );
foreach ($screens as $screen) {
add_meta_box('indtable_boxid', __( 'Pricing Table', 'pricing_table' ),
'ind_pricing_tables_boxes_form', $screen );
}
}
function ind_pricing_tables_boxes_form() {
global $post;
wp_nonce_field( 'ind_pricing_table_box_nonce' );
$ind_table_packs = get_post_meta($post->ID,
"_ind_meta_table_keypacks", true);
$ind_table_packs = ($ind_table_packs == '') ? array() :
json_decode($ind_table_packs);
$query = new WP_Query(array(
'post_type' => 'indpackage',
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'post_date',
'order' => 'ASC'
)
);
$ind_form_box = '<table class="form-table" border="1">';
$ind_form_box .= "<tr><th style=''>
<b>Select Package</b>
</th>
<td>
<b>Package Names</b>
</td></tr>";
while ($query->have_posts()) : $query->the_post();
$checked_whichs = (in_array($query->post->ID, $ind_table_packs)) ?
"checked" : "";
$ind_form_box .= "<tr><th style=''>
<input type='checkbox'
name='pricing_ind_table_packages[]' $checked_whichs
value='" . $query->post->ID . "' />
</th><td>" . $query->post->post_title . " </td></tr>";
endwhile;
$ind_form_box .= '</table>';
echo $ind_form_box ;
}
What causing the error?
No comments:
Post a Comment