WordPress.org

Ready to get started?Download WordPress

Forums

Plugin to specify language of individual pages (3 posts)

  1. jezbutler
    Member
    Posted 1 year ago #

    Hi

    I'm running a bilingual site and would like to specify the langauge of a page. I don't need a translation tool, just something that lets me specify the languae in the document head.

    Thanks in advance

    Jez

  2. softwaretalk
    Member
    Posted 1 year ago #

    hi jezbutler, if you are talking about the language attributes for the html tag take a look at the language_attributes hook, if you mean the language meta tag, you can just hook in wp_head and echo it.

    In short it could look something like this:

    // result: <html lang="en-US"> or <html lang="de-DE"> depending on $use_english
    add_filter('language_attributes', $use_english ? 'en-US' : 'de-DE');

    Here is a post I wrote about specifying the language tag and I also wrapped it up in a plugin. I do not know how you would decide which language a post is, but it should also be quite easy to add an option to the "add new post"-page and set the language info on a per-post basis manually.

  3. jezbutler
    Member
    Posted 1 year ago #

    Thanks very much... I'll investigate shortly!

    Cheers

    Jez

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags