0

that will add lang="ur" attribute in page's main <body> tag. How I can do that? I try different plugin including polylang, but look not working. Please suggest plugin if you know or do some simple coding.

6
  • What does your question have to do with the "page attributes" widget? Oct 6, 2013 at 9:57
  • @helgatheviking I want to add new Checkbox on the page attribute's widget.
    – John Doe
    Oct 6, 2013 at 10:01
  • If this is related to your other question about showing Custom Fields, you may consider a plugin like Advanced Custom Fields, or creating your own Custom Meta Box if you're in coding mood.
    – brasofilo
    Oct 6, 2013 at 13:49
  • Sorry it seems that your question is a continuation of your title, so I misunderstood. As brasofilio mentioned, you'll need to create a metabox, and then you can implement Patrick Saad's solution. Oct 6, 2013 at 14:29
  • @brasofilo My other question is bit different from it. Here i want to add lang attribute only with title element. But there I want to add with body element.
    – John Doe
    Oct 6, 2013 at 14:39

1 Answer 1

3

You can create a custom field, give it a value of lang='ur' and check for it in your header.php.

  1. Add the custom field from the Custom Fields box. Let's call it page_lang. Give it a value of lang='ur'.

In header.php:

<?php
global $post;
$lang = get_post_meta(get_the_ID(), 'page_lang', true);
?>
<body <?php body_class();?> <?php echo $lang;?>>

Each page you want to show this lang, you just select the 'page_lang' custom field and give it the value you want (you have the option to write any value you want, thus any other language than 'ur').

1
  • Really thanks, that much simpler then I think. Thanks again
    – John Doe
    Oct 6, 2013 at 10:03

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.