Forums

Stop "language_attributes" producing invalid XHTML 1.1? (6 posts)

  1. Robot Armadillo
    Member
    Posted 2 years ago #

    I'm trying to make an XHTML 1.1 theme. I'm using the "language_attributes" function in the header, as recommended.

    <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes('xhtml'); ?>>

    However, this produces the following.

    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en-US">

    "lang" is invalid markup in XHTML 1.1 - only "xml:lang" is allowed.

    Is there anyway of having WordPress return the correct attributes? I could modify the language_attributes function to be able to take an "xhtml 1.1" attribute, but I'd prefer not to mod the WordPress code, as it's a pain when updating.

  2. apljdi
    Member
    Posted 2 years ago #

    The function calls a filter just before outputting to the browser so you should be able to use that to remove the offending attribute.

  3. Robot Armadillo
    Member
    Posted 2 years ago #

    Thanks. That worked a treat...after I dusted off my old PHP skills.

  4. maorba
    Member
    Posted 2 years ago #

    Could you give here an example for such a filter?
    Thanks

  5. abstractic
    Member
    Posted 2 years ago #

    The correct way to parse the language in that meta tag is as simple as this:

    <meta http-equiv="Content-language" content="<?php bloginfo('language'); ?>" />

  6. abstractic
    Member
    Posted 2 years ago #

    Sorry think I was too quick there, the correct headers should be:

    <html xmlns="http://www.w3.org/1999/xhtml" dir="<?php bloginfo('text_direction'); ?>" xml:lang="<?php bloginfo('language'); ?>">

    <head>

    <title>The title</title>

    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    <meta http-equiv="Content-language" content="<?php bloginfo('language'); ?>" />

Topic Closed

This topic has been closed to new replies.

About this Topic