block editor - admin_notices not shown

admin2025-06-02  3

I have updated my WordPress site to 5.0.3. In my functions.php there is a hook for admin_notices which worked before. After the update the notice is still rendered but moved to a div wich is not displayed (display: none).

I followed this documentation

Am I missing something with the new editor?

EDIT

Sorry, this is my first question ever. Here is my code.

function my_admin_notices() {
    global $post, $pagenow;

    if (!is_admin()) return;

    if ( ! in_array( $pagenow, array( 'post-new.php' ) ) ) return;

    if ( ! in_array( $post->post_type, array( 'post' ) ) ) return;

    echo '<div class="notice notice-info"><p>This is just a test.</p></div>';
}
add_action( 'admin_notices', 'my_admin_notices' );

I also copied the code from the documentation page into my functions.php with the same result that the notice is not displayed. I should mention that this is a multisite installation but as I said before, it worked with WP 4.9.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748863974a314353.html

最新回复(0)