Change 'post published' text
-
Hi
Is is possible to change the text after a user has published a post? Instead of saying ‘post published’ I’d like to write something a bit longer.
I don’t want to edit the core WP files, is there a way to do this in functions?
Thanks,
Ian
-
I don’t suggest editing files o your wordpress but if you insist,i guess you can do this. Please try it and see if it works. You can do it by going to wp-admin/edit-form-advanced.php and opening this file and editing below line:
6 => sprintf( __('Post published. <a href="%s">View post</a>'), esc_url( get_permalink($post_ID) ) ),
Thanks for the info, but I said above I don’t want to edit WordPress files, I am looking for a solution that can be updated in my theme if possible?
Thanks,
Ian
You might be able to do something via the
'post_updated_messages'
filter. But this is not something I’ve tried myself, so this is totally untested:function my_post_published_message( $messages ) { $messages['page'][6] = sprintf( __('Your message here') ); return $messages; } add_filter( 'post_updated_messages', 'my_post_published_message' );
Thanks @esmi, unfortunately that code didn’t work. Still returned the default message.
Can you try:
function my_post_published_message( $messages ) { $messages['page'][6] = sprintf( __('Your message here') ); echo '<pre>'; print_r($messages); echo '</pre>'; return $messages; } add_filter( 'post_updated_messages', 'my_post_published_message' );
to see if anything is output?
Yes, the following (before I have published the project:
Array
(
[post] => Array
(
[0] =>
[1] => Project updated. View Project
[2] => Custom field updated.
[3] => Custom field deleted.
[4] => Project updated.
[5] =>
[6] => Project published. View Project
[7] => Project saved.
[8] => Project submitted. Preview Project
[9] => Project scheduled for: Oct 4, 2013 @ 12:07. Preview Project
[10] => Project draft updated. Preview Project
)[page] => Array
(
[0] =>
[1] => Page updated. View page
[2] => Custom field updated.
[3] => Custom field deleted.
[4] => Page updated.
[5] =>
[6] => Your message here
[7] => Page saved.
[8] => Page submitted. Preview page
[9] => Page scheduled for: Oct 4, 2013 @ 12:07. Preview page
[10] => Page draft updated. Preview page
)[attachment] => Array
(
[1] => Media attachment updated.
[2] => Media attachment updated.
[3] => Media attachment updated.
[4] => Media attachment updated.
[5] => Media attachment updated.
[6] => Media attachment updated.
[7] => Media attachment updated.
[8] => Media attachment updated.
[9] => Media attachment updated.
[10] => Media attachment updated.
)[acf] => Array
(
[0] =>
[1] => Field group updated.
[2] => Custom field updated.
[3] => Custom field deleted.
[4] => Field group updated.
[5] =>
[6] => Field group published.
[7] => Field group saved.
[8] => Field group submitted.
[9] => Field group scheduled for.
[10] => Field group draft updated.
))
Skip to main contentAnd then this, after publishing (note, still says ‘post published’)
Array
(
[post] => Array
(
[0] =>
[1] => Project updated. View Project
[2] => Custom field updated.
[3] => Custom field deleted.
[4] => Project updated.
[5] =>
[6] => Project published. View Project
[7] => Project saved.
[8] => Project submitted. Preview Project
[9] => Project scheduled for: Oct 4, 2013 @ 12:08. Preview Project
[10] => Project draft updated. Preview Project
)[page] => Array
(
[0] =>
[1] => Page updated. View page
[2] => Custom field updated.
[3] => Custom field deleted.
[4] => Page updated.
[5] =>
[6] => Your message here
[7] => Page saved.
[8] => Page submitted. Preview page
[9] => Page scheduled for: Oct 4, 2013 @ 12:08. Preview page
[10] => Page draft updated. Preview page
)[attachment] => Array
(
[1] => Media attachment updated.
[2] => Media attachment updated.
[3] => Media attachment updated.
[4] => Media attachment updated.
[5] => Media attachment updated.
[6] => Media attachment updated.
[7] => Media attachment updated.
[8] => Media attachment updated.
[9] => Media attachment updated.
[10] => Media attachment updated.
)[acf] => Array
(
[0] =>
[1] => Field group updated.
[2] => Custom field updated.
[3] => Custom field deleted.
[4] => Field group updated.
[5] =>
[6] => Field group published.
[7] => Field group saved.
[8] => Field group submitted.
[9] => Field group scheduled for.
[10] => Field group draft updated.
))
Skip to main contentThanks,
Ian
Try:
function my_post_published_message( $messages ) { $messages['post'][6] = sprintf( __('Your message here') ); return $messages; } add_filter( 'post_updated_messages', 'my_post_published_message' );
Nailed it ??
Cheers @esmi
Cool! ??
- The topic ‘Change 'post published' text’ is closed to new replies.