I am creating multilingual website in Urdu & English lanugage on Wordpress. Major part of site is in English. Only article's body (i.e paragraph & headings etc) are in Urdu. To assign Urdu fonts to urdu content, when writing article, I just switch to HTML Mode and insert lang="ur" attribute with elements and style them in CSS by :lang() pseudo selector.

Now I get problem that how I can specifie lang attribute for Post/Page title? Any idea?

I hope you will understand what I want to say. Thanks

1 Answer 1


There is a the_title filter. You should be able to wrap the title in a <span> using that.

  function($title) {
    return '<span lang="ur">'.$title.'</span>';

A version compatible with an older PHP:

function lang_attr_wpse_116733($title) {
  return '<span lang="ur">'.$title.'</span>';

If it were me, I'd add a checkbox on the post edit screen somewhere and then wrap both the title and the post body with a <span> or <div> based on that single checkbox.

  • Thank you for answer but above code is not working. I get this error: "Parse error: syntax error, unexpected T_FUNCTION in /home1/tissosas/public_html/asanpaisa.com/wp-content/themes/academy/functions.php on line 52" What is wrong? Please describe more. I am new to java. Thanks
    – John Doe
    Commented Oct 4, 2013 at 14:31
  • @JohnTossot : I think you are running an older PHP. See the edit.
    – s_ha_dum
    Commented Oct 4, 2013 at 14:36
  • Thank you its working. But how I can add checkbox to my widget to make one click lang attribute addition as you give idea in you answer?
    – John Doe
    Commented Oct 4, 2013 at 14:42
  • Sorry? That last comment contains the first mention of "widget" I've seen in this question? Second, you aren't dealing with "java". This is PHP. Third, I didn't elaborate about the checkbox because it isn't really part of the question and the solution would be rather long. Search this site for questions about adding meta boxes and see if you can't get started.
    – s_ha_dum
    Commented Oct 4, 2013 at 14:50

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.