Skip to content

Instantly share code, notes, and snippets.

@jshwlkr
Created February 15, 2022 21:03
Show Gist options
  • Save jshwlkr/1bfbc096c3d7247c321f06e8f179c91f to your computer and use it in GitHub Desktop.
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
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"';
}
@jshwlkr
Copy link
Author

jshwlkr commented Feb 15, 2022

May want to filter out the admin, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment