I have two translatable strings as follows in my 404.php file

esc_html_e( 'I couldn't find the page you were looking for.', 'themename' );
esc_html_e( 'Try a search or one of the links below.', 'themename' );

At its present form, the first string does not get translated. Escaping the single quote with a backslash does not help either.

Any ideas?

  • Easiest way out is simply write 'could not', though there's probably a smarter way.
    – cjbj
    Jun 18, 2016 at 10:03
  • Right, but that makes it formal. Besides, I prefer to know a solution to this problem in terms of programming and learn something. Thanks anyway.
    – developer
    Jun 18, 2016 at 10:09

2 Answers 2


You can wrap it inside double quotes:

esc_html_e("I couldn't find the page you are looking for.", "themename");

You can also escape the single quote:

esc_html_e( 'I couldn\'t find the page you were looking for.', 'themename' );

But the PHP Coding Standards of WordPress recommend to not escape any characters:

Single and Double Quotes

Use single and double quotes when appropriate. If you’re not evaluating anything in the string, use single quotes. You should almost never have to escape quotes in a string, because you can just alternate your quoting style.

So you are probably better of, using double quotes as stated by user6454281 already:

esc_html_e( "I couldn't find the page you were looking for.", 'themename' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.