WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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');
share|improve this question
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 '12 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. – Sol Dec 7 '12 at 1:48

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' );
share|improve this answer
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 – Sol Dec 7 '12 at 1:04
@Sol, use global $pagenow, $post; and get the information you need from $post, like: $post->post_parent. – brasofilo Dec 7 '12 at 1:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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