I want to wrap <strong></strong>
around the words “logged out”:
add_filter( 'gettext', 'wpse17709_gettext', 10, 2 );
function wpse17709_gettext( $custom_translation, $login_texts ) {
// Messages
if ( 'You are now logged out.' == $login_texts ) { return ''; } // Log out message
return $translation
}
…however adding HTML elements to the text string breaks my page.
How can I add <strong></strong>
to this message text? Is there a means other than gettext
?
3 Answers
This allows for the message to be overwritten specifically for the loggedout
message while leaving all other messages alone. Here is more documentation on the filter.
add_filter( 'wp_login_errors', 'my_logout_message' );
function my_logout_message( $errors ){
if ( isset( $errors->errors['loggedout'] ) ){
$errors->errors['loggedout'][0] = 'This is the <strong style="color:red;">logged out</strong> message.';
}
return $errors;
}