Found 2 elements with non-unique id (#_ajax_nonce) and (#_wpnonce)
I am developing custom theme from scratch and creates a custom post type and getting this warning while editing custom post type. I also design custom Meta box with two input fields and using nonce in it. Any help removing these warning?
Here is code of custom metabox in functions.php
//Custom Metabox
function register_book_meta_box(){
add_meta_box('book_meta_box_id', 'Book Detail','design_book_meta_box','books','advanced','high');
}
add_action('add_meta_boxes','register_book_meta_box');
function design_book_meta_box($post){
wp_nonce_field(basename(__FILE__),'book_cpt_nonce')
?
div
label for=book-authorAuthor Namenbsp;nbsp;/label
input type=text name=book-author placeholder=Author Name value=?php echo get_post_meta( $post-ID, 'book-author-key', true );?
/div
div
label for=yearPublished Year/label
input type=number id=year name=year min=1455 max=2020 value=?php echo get_post_meta( $post-ID, 'book-year-key', true );?
span id=errorMsg style=display:none;Published Year Must be range from 1455 - 2020/span
/div
?php
}
function save_book_meta_data($post_id)
{
if(!isset($_POST['book_cpt_nonce']) || !wp_verify_nonce($_POST['book_cpt_nonce'],basename(__FILE__))){
return $post_id;
}
if (array_key_exists('book-author', $_POST)) {
update_post_meta( $post_id,'book-author-key', $_POST['book-author']
);
}
if (array_key_exists('year', $_POST)) {
update_post_meta( $post_id,'book-year-key', $_POST['year']
);
}
}
add_action('save_post', 'save_book_meta_data');
Topic nonce metabox custom-field custom-post-types Wordpress
Category Web