Archived topic
Add Head Attributes
6 replies · Started by Michelle on March 16, 2021
Hi there,
So we keep getting this & my website coder says it's b/c of the theme template.
[warn] SSO Notice: At least one of your theme header templates does not offer a recognized way to modify the head HTML tag attributes. Adding the document Schema item type to the head HTML tag attributes is important for Pinterest. It is also important for Google in cases where Schema markup describing the content is not available in the webpage (for example, when the complementary WPSSO JSON add-on is not active). The <head> HTML tag in your header template(s) should include a function, action, or filter for its attributes. WPSSO Core can update your header template(s) automatically and change the existing <head> HTML tag to: <head <?php do_action( 'add_head_attributes' ); ?>> Click here to update header template(s) automatically (recommended) or update the template(s) manually. This notice can be dismissed permanently.
I don't want to have to keep clicking on links in all of my sites & after updating the theme if you can add this please.
Thanks
Hi there,
you can use the language_attributes filter:
https://developer.wordpress.org/reference/functions/language_attributes/
Example of it here being used for adding attributes:
Ok, thanks. I wrote to WP SSO. Let's hope they add you guys.
This isn't an action I've personally heard of, and it doesn't seem to exist in any of the core Twenty-x themes. Sounds like something the plugin itself should be offering a solution for without requiring a custom action in the theme.
Hi Tom,
How are you doing?
Ok, this is all greek to me, so I'm going to type what my website coder is saying because he read what WPSSO said in their support response...
"How is a plugin supposed to add code into the html tag?"
He's not a theme developer, so maybe he's missing something.
Thanks
They would use the language_attributes filter: https://developer.wordpress.org/reference/functions/get_language_attributes/
Whenever something like this comes up, it's best to check the default WordPress themes for best-practices. As we can see here, there is no add_head_attributes action in the <head> element: https://github.com/WordPress/WordPress/blob/5.7/wp-content/themes/twentytwentyone/header.php#L16
If WPSSO has any reading on this action they'd like to share, I'd love to read it. I'm not able to find anything.
Hi Tom,
Sorry, Chris meant the head tag, not the html tag.
We wrote to them & I'll get back to you when I hear back.
Thanks