I’m confused about some of the messages that can appear on a post entry/edit screen in the admin area:
$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.' ),
8 => __( 'Post submitted.' ) . $preview_post_link_html,
9 => sprintf( __( 'Post scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
10 => __( 'Post draft updated.' ) . $preview_post_link_html,
);
For instance, what is the difference between indices 1 and 4? When is one called, versus the other? Also, what is the difference between indices 7, 8, and 10? They sound like they would appear if you’re saving a draft of a post that has not yet been published (which would trigger #6.)
I haven’t been able to find any kind of guide for which message occurs at what time.
Thanks for shedding some light on the subject!
1 Answer
Good question! Let’s shed some light at this.
First of all, it’s worth noting that these messages can be overridden via the post_updated_messages
filter. Thus, they could be slightly different depending on which plugins you use.
There are different functions responsible for appending &message=<number>
to the URL (which determines the message being shown). You might have never seen this query parameter because WordPress removes it on page load (see wp_removable_query_args()
). This way, you’ll never see the message again when you simply reload the page.
- Used when updating an already published post.
Function:redirect_post()
- Used when you add a new meta value to a post and click on “Add Custom Field”.
Appears to be only used when JS is disabled.
Function:redirect_post()
- Used when you delete a single meta value by clicking “Delete”.
Appears to be only used when JS is disabled.
Function:redirect_post()
- This appears to be the fallback message when the origin of the request is unclear.
The user will be redirected to the edit post screen.
Function:redirect_post()
- Used when restoring a specific post revision.
File:wp-admin/revision.php
- Default message when you publish a new post. Includes the the link to view it.
Function:redirect_post()
- This message doesn’t appear to be used right now.
I might be wrong, tough. I’ll update this if it turns out it is used. - Default message when you save a post as “Pending Review”.
Usually the case when you don’t have the capability to publish posts on your own.
Function:redirect_post()
-
Default message when you schedule a post for a future date.
Function:redirect_post()
-
Default message when you you edit a draft post. Includes the link to preview it.
Function:redirect_post()