admin管理员组文章数量:1130349
I am creating my first WP plugin and I'm having a some issues when trying to move a custom post type to the bin.
I have a custom post type and in this I have a custom meta box with four fields. I can see, save and permanently delete my data through the WP admin without problem but when I try moving a post to the bin I get an Undefined Index error against each of my fields. My code that saves the post data and where the error occurs is as follows:
function save_glass_types_admin($post_id, $post, $update) {
if( !$update ) {
return;
}
$glass_group = sanitize_text_field($_POST['glass_group']);
$glass_colour = sanitize_text_field($_POST['glass_colour']);
$glass_colour_ref = sanitize_text_field($_POST['glass_colour_ref']);
$glass_image_url = sanitize_text_field($_POST['glass_image_url']);
update_post_meta($post_id, 'glass_group', $glass_group);
update_post_meta($post_id, 'glass_colour', $glass_colour);
update_post_meta($post_id, 'glass_colour_ref', $glass_colour_ref);
update_post_meta($post_id, 'glass_image_url', $glass_image_url);
}
I am calling this function from the index.php as follows:
add_action('save_post_glass-types', 'save_glass_types_admin', 10, 3);
I also have an include here:
include('process/save_post.php');
Please can anyone help show me where I am going wrong?
Many thanks in advance.
I am creating my first WP plugin and I'm having a some issues when trying to move a custom post type to the bin.
I have a custom post type and in this I have a custom meta box with four fields. I can see, save and permanently delete my data through the WP admin without problem but when I try moving a post to the bin I get an Undefined Index error against each of my fields. My code that saves the post data and where the error occurs is as follows:
function save_glass_types_admin($post_id, $post, $update) {
if( !$update ) {
return;
}
$glass_group = sanitize_text_field($_POST['glass_group']);
$glass_colour = sanitize_text_field($_POST['glass_colour']);
$glass_colour_ref = sanitize_text_field($_POST['glass_colour_ref']);
$glass_image_url = sanitize_text_field($_POST['glass_image_url']);
update_post_meta($post_id, 'glass_group', $glass_group);
update_post_meta($post_id, 'glass_colour', $glass_colour);
update_post_meta($post_id, 'glass_colour_ref', $glass_colour_ref);
update_post_meta($post_id, 'glass_image_url', $glass_image_url);
}
I am calling this function from the index.php as follows:
add_action('save_post_glass-types', 'save_glass_types_admin', 10, 3);
I also have an include here:
include('process/save_post.php');
Please can anyone help show me where I am going wrong?
Many thanks in advance.
本文标签: plugin developmentError when moving custom post type to bin
版权声明:本文标题:plugin development - Error when moving custom post type to bin 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749200036a2331641.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论