Created
February 15, 2022 21:03
-
-
Save jshwlkr/1bfbc096c3d7247c321f06e8f179c91f to your computer and use it in GitHub Desktop.
Alter your WordPress page meta (like changing the html element) based on post template
This file contains 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
function prefix_template_meta() { | |
if (get_page_template_slug() == 'page template slug') { | |
// This is an arbitrary operation, in this case. You could do anything here. | |
// Beware making assumptions about the availability of things, like the post ID, if you change the action hook. | |
add_filter( 'language_attributes', 'prefix_xml_namespaces' ); | |
} | |
} | |
add_action('wp','prefix_template_meta'); | |
function prefix_xml_namespaces($output) { | |
return $output . ' xmlns="http://www.w3.org/1999/xhtml"'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
May want to filter out the admin, etc.