“Notice: Undefined index:” error when adding new content?

Whoever wrote your theme didn’t bother to verify the existence of array keys before using them. The error is happening because the key album_tracks_metabox_nonce doesn’t exist in the $_POST array.

The line likely should be:

if (
  !isset($_POST['album_tracks_metabox_nonce']) ||
  !wp_verify_nonce($_POST['album_tracks_metabox_nonce'], 'album_tracks_metabox')
) {
  // whatever is in the if condition, likely `return`
}

Leave a Comment