Note that the_author_meta()
doesn’t return the meta value, but echoes it. That’s why the name is suddenly outside the <p>
element.
Use get_the_author_meta()
if you need to return (and do something with) the field, rather than just display it.
I’d highly recommend you to change your use usage of __()
too, because that is not useful for translators as it’s missing the name as context.
/* translators: %s: user's first name */
$text = sprintf(
__( "%s hasn't published any articles yet.", 'monochrome-pro' ),
esc_html( get_the_author_meta( 'user_firstname' ) )
);
echo '<p>' . $text . '</p>';
Note: if you don’t trust your translations, you should use esc_html()
on $text
instead of the user meta. As mentioned in the comments, using KSES functions is a bit overkill. If you want to get rid of any HTML tags (vs. just escaping them) I’d use wp_strip_all_tags()
.