public function update($new_instance, $old_instance) {
    $instance = array();
    if ( ! empty( $new_instance['title'] ) ) {
        $instance['title'] = sanitize_text_field( $new_instance['title'] );
    }
    if ( ! empty( $new_instance['newsletter_title'] ) ) {
        $instance['newsletter_title'] = sanitize_text_field( $new_instance['newsletter_title'] );
    }
    if ( ! empty( $new_instance['newsletter_description'] ) ) {
        $instance['newsletter_description'] = sanitize_text_field( $new_instance['newsletter_description'] );
    }
    if ( ! empty( $new_instance['mailchimp_api_key'] ) ) {
        $instance['mailchimp_api_key'] = sanitize_text_field( $new_instance['mailchimp_api_key'] );
    }
    if ( ! empty( $new_instance['mailchimp_list_id'] ) ) {
        $instance['mailchimp_list_id'] = sanitize_text_field( $new_instance['mailchimp_list_id'] );
    }
    return $instance;
    $random=rand(1,10000);

}

The above is the Update function. when I enter the values in the form they get saved in the database and get updated on the front end. However, they do not get printed in the backend form that means they do not get saved in the backend form. What is the issue? This Video should help understand what I mean to say.

Pasting the whole code make it a menace sometimes to read what matters in a question. Therefore I have uploaded the whole widget here in case if that is needed.

Read more here: Instances Not Updating in WordPress Widget update Method


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: