This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
post_updated_messages filter
This filter hook allows you to modify the post updated messages. It’s pretty handy when you need to customize the messages displayed after a post is updated.
Hook Syntax:
apply_filters('post_updated_messages', array[] $messages)
Description
The post_updated_messages filter hook is used to filter the post updated messages. It consists of one parameter, an array of $messages.
Parameters
- $messages: (array[]) Post updated messages. For defaults, see $messages declarations above.
Live Examples
Example 1: Basic Usage of the Hook
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... }
Example 2: Adding a Hook Callback
The following example demonstrates how to add a hook callback.
// define the post_updated_messages callback function weplugins_filter_post_updated_messages($array) { // make filter magic happen here... return $array; }; // add the filter add_filter('post_updated_messages', 'weplugins_filter_post_updated_messages', 10, 1);
Example 3: Removing a Hook Callback
To remove a hook callback, use the example below.
// remove the filter remove_filter('post_updated_messages', 'weplugins_filter_post_updated_messages', 10, 1);
Customizing Post Updated Messages
Here’s an example of how the $messages array might be structured:
$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.'), /* additional messages */ );
Contact Us
If you need any customization or further assistance, feel free to contact us.
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.