I am trying to add a custom info notice after the post has been deleted from the trash, but I’m not having any luck with it
add_action( 'delete_post', 'show_admin_notice' );
/**
* Show admin notice after post delete
*
* @since 1.0.0.
*/
function show_admin_notice(){
add_action( 'admin_notices', 'show_post_order_info' );
}
/**
* Display notice when user deletes the post
*
* When user deletes the post, show the notice for the user
* to go and refresh the post order.
*
* @since 1.0.0
*/
function show_post_order_info() {
$screen = get_current_screen();
if ( $screen->id === 'edit-post' ) {
?>
<div class="notice notice-info is-dismissible">
<p><?php echo esc_html__( 'Please update the ', 'nwl' ) . '<a href="' . esc_url( admin_url( 'edit.php?page=post-order' ) ). '">' . esc_html__( 'post order settings', 'nwl' ) . '</a>' . esc_html__( ' so that the posts would be correctly ordered on the front pages.', 'nwl' ); ?></p>
</div>
<?php
}
}
I’m clearly missing something here, but I couldn’t find out what on the google.
If I just use the admin_notices
hook, I’ll get the notice shown always on my posts admin page