0

I'm working on a plugin with a custom post type called "important_dates"

I want to delete the Wordpress admin notification when a new custom post is created.

Here is my code - it deletes the notifications for all post types. How do I make it work for only my "important_dates" custom post type?

add_filter( 'post_updated_messages', 'post_published' );

function post_published( $messages )
{
    unset($messages['posts'][6]);
    return $messages;
}
}

2 Answers 2

1

Something like above should work:

add_filter( 'post_updated_messages', 'post_published' );

function post_published( $messages )
{
   if ( 'important_dates' === get_post_type() ){
       unset($messages['posts'][6]);
   }
   return $messages;
}

1
  • Awesome - thank you! Jan 29, 2022 at 21:00
1

Here is the full code


function post_published( $messages )
{
  if ( 'important_dates' === get_post_type() ){
    unset($messages['posts'][6]);
  } else {
    return $messages;
}
}
1
  • thank you I've corrected my code below because in my first case like in yours, sometines $messages isn't returned. Now it is. Jan 30, 2022 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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