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">
     <p>some help text</p>   
add_action('admin_notices', 'my_admin_notice');
  • Not directly related, but take a look at contextual_help to add your own help topics in the Help tab, or even replace the defaults.
    – brasofilo
    Dec 7, 2012 at 1:14
  • No, that is not helpful at all and is not relevant to my question. I'm not looking for contextual help functionality. I already have a help message displaying just fine, I simply need it to show on child posts as well. Thanks anyway. Dec 7, 2012 at 1:48

1 Answer 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' );
  • Thank you for your fast response and effort, but this still does not work on the child posts. FYI the child posts are not displaying the parent post type name, instead they look like this: wp-admin/post.php?post=146&action=edit Dec 7, 2012 at 1:04
  • @Sol, use global $pagenow, $post; and get the information you need from $post, like: $post->post_parent.
    – brasofilo
    Dec 7, 2012 at 1:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.