Created
June 23, 2023 21:02
-
-
Save xardit/b498e366240020ca3df45c65a6d6865a to your computer and use it in GitHub Desktop.
WP Change Language Attribute on HEAD based on specific slug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// set language attribute of the main <html> tag based on category value | |
function new_language_attributes($lang){ | |
if(is_single()) { | |
$ar = get_the_category(); | |
foreach($ar as $c) { | |
if($c->slug=='in-italiano') { | |
return "lang=\"it\""; | |
} | |
} | |
} | |
return $lang; | |
} | |
add_filter('language_attributes', 'new_language_attributes'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment