Show admin help message across custom post type parent and child posts

In my custom plugin, I am using the following code to display an info / help box.

This is working great for the main admin edit screen that lists the custom posts, but how can I extend this to show the message at the top of each of the actual child custom posts too.

function my_admin_notice(){
global $pagenow;
if ($_GET['post_type'] == 'my_custom_post_type' ) {
 echo '
     <div class="updated">
     <h3><strong>Help</strong></h3>
     <p>some help text</p>   
     </div>';
}
}
add_action('admin_notices', 'my_admin_notice');

Related posts

Leave a Reply

1 comment

  1. You’ll need to check the $pagenow variable and the post type of the post being edited. It will look something like this:

    function wpse_75224_admin_notices() {
        global $pagenow;
    
        $is_edit_custom_post_type = ( 'post.php ' == $pagenow && 'my_custom_post_type' == get_post_type( $_GET['post'] ) );
        $is_new_custom_post_type = ( 'post-new.php' == $pagenow && 'my_custom_post_type' == $_GET['post_type'] );
        $is_all_post_type = ( 'edit.php' == $pagenow && 'my_custom_post_type' == $_GET['post_type'] );
    
        if ( $is_all_post_type || $is_edit_custom_post_type || $is_new_custom_post_type ) {
            echo "Your message.";
        }
    }
    
    add_action( 'admin_notices', 'wpse_75224_admin_notices' );