admin管理员组

文章数量:1122832

I need some help with the rest mode error handling in WP. In my CPT I use a metabox with different fields. If the user save the post there must be an error handling on the metabox fields.

With the Gutenberg editor I can use this for example

add_settings_error(
    'missing-link',         
    'missing-link',         
    'Link may not empty!',          
    'error' 
);
add_action('admin_notices', function(){
    $message = '<div id="message" class="error"><p><ul>';         
    foreach ( $errors as $error ) {         
        $message .= '<li>' . $error['message'] . '</li>';         
    }         
    $message .= '</ul></p></div>';      
    echo $message;
});

But this does not work on the block editor / rest mode

How can I create my own error messages on the custom fields?

Hope somebody can help me a little with this

本文标签: Create error handling metabox fields WP block editorrest mode