Exciting News! Flipper Code is now WePlugins! Same commitment to excellence, brand new identity.

How to use post_updated_messages filter in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
July 9, 2022
5 minutes read

post_updated_messages filter

Filters the post updated messages.

apply_filters( 'post_updated_messages', array[] $messages )

Description

This is filter hook , its filter the post updated messages.
Its consists of one parameter, that is array of $messages.

Parameters

  • $messages : (array[]) Post updated messages. For defaults see $messages declarations above.

Live Example

To run the hook, copy the example below.

$array = apply_filters( 'post_updated_messages', $array ); 
                         
if ( !empty( $array ) ) { 
                         
   // everything has led up to this point... 
                         
} 
   
  

The following example is for adding a hook callback.

// define the post_updated_messages callback 
function filter_post_updated_messages( $array ) { 
    // make filter magic happen here... 
    return $array; 
}; 
         
// add the filter 
add_filter( 'post_updated_messages', 'filter_post_updated_messages', 10, 1 ); 

To remove a hook callback, use the example below.

// remove the filter 
remove_filter( 'post_updated_messages', 'filter_post_updated_messages', 10, 1 ); 
$messages['post'] = array(
    0  => '', // Unused. Messages start at index 1.
    1  => __( 'Post updated.' ) . $view_post_link_html,
    2  => __( 'Custom field updated.' ),
    3  => __( 'Custom field deleted.' ),
    4  => __( 'Post updated.' ),
    /* translators: %s: date and time of the revision */
    5  => isset( $_GET['revision'] ) ? sprintf( __( 'Post restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
    6  => __( 'Post published.' ) . $view_post_link_html,
    7  => __( 'Post saved.' ),
   . '</strong>' ) . $scheduled_post_link_html,
 ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
   . '</strong>' ) . $scheduled_page_link_html,
 ) ); // Hack, for now.

Explore the latest in WordPress

Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.