Removing esc_html_e() or have a link inside

Hi there,

I would like to change some text in my WordPress files with a link, but have noticed it is using esc_html_e()

<li><?php is_user_logged_in()
					? esc_html_e( 'You cannot reply to this topic.',               'bbpress' )
					: esc_html_e( 'You must be logged in to reply to this topic.', 'bbpress' );
				?></li>

I would like to add a link inside the above sentence, so the word “logged in” is linked.

Can someone tell me how I can use HTML in this line so it doesn’t remove HTML?

Something like:
You must be <a href="/login">logged</a> in to reply to this topic

Thanks

Try this:

<li>
<?php
is_user_logged_in()
  ? esc_html_e( 
   'You cannot reply to this topic.', 'bbpress' 
)
 : esc_html_e( 
'<a href="/login">logged</a> in to reply to this topic
' , 'bbpress'
);
?>
</li>

Beware:
Tapped on a tablet and not tried.

1 Like

Thank you, that worked perfectly:)

Why do you need to HTML escape a hardcoded string? There is no user input, so no need to escape anything :thinking:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.