最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

notifications - Delete "Post Published. View Post" for custom post type

programmeradmin4浏览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;
}
}

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;
}
}
Share Improve this question asked Jan 29, 2022 at 19:53 Doug HigsonDoug Higson 386 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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;
}

Here is the full code


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

评论列表(0)

  1. 暂无评论