It apparently seem like a duplicate question (Undefined 'post_type' error on Add new page), I've tried solving since a last few hours along with researching and now it's time to ask from experts.

I tried using the following two ways to create nonce field from add_meta_box callback function.

wp_nonce_field( 'meta_slider_noncename', 'abc');


 <input type="hidden" name="my_nonce" value="<?php echo wp_create_nonce('the_nonce'); ?>">

Upon inspecting the Add New Page from CPT, the nonce field is actually added. I am using it in theme, not plugin.

and from save_post callback function, I tried this as suggested in other ways to confirm if $_POST key isset and nonce exists

if (!isset($_POST['abc'])) {

    if(!wp_verify_nonce($_POST['abc'],'meta_slider_noncename')) {

but the error still persists. What am I doing wrong here?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.