How should I properly escape the single quote character in a translation string? I'm using it as an apostrophe. For example:

__( '404. This isn't the page you're looking for.', 'textdomain' );

I believe there are a few approaches but which is the proper way?

Approach 1: Using the backslash:

__( '404. This isn\'t the page you\'re looking for.', 'textdomain' );

Approach 2: Using the character entity:

__( '404. This isn't the page you're looking for.', 'textdomain' );
  • What does proper mean? How about double quotes?
    – Minh Tri
    Jun 26, 2016 at 10:39
  • 1
    Sorry, think it may be my British. Proper "of the required or correct type or form; suitable or appropriate." Jun 26, 2016 at 10:49

1 Answer 1


Use the first option. translated strings are supposed to be "raw", and escaped only by the calling function. In addition many will not understand what ' mean and how to translate it without looking at the actual page which can be annoying.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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