Last active
November 22, 2023 17:50
-
-
Save sybrew/272b746296114cd93c3320e9544a1618 to your computer and use it in GitHub Desktop.
TSF meta render data filter
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
<?php | |
// This works on TSF v5.0 and later. | |
add_filter( | |
'the_seo_framework_meta_render_data', | |
function ( $tags_render_data ) { | |
// Remove og:description: | |
unset( $tags_render_data['og:description'] ); | |
// Set robots content to 'noindex': | |
$tags_render_data['robots']['attributes']['content'] = 'noindex'; | |
// Set twitter:description's content to 'hello world!': | |
$tags_render_data['twitter:description']['attributes']['content'] = 'hello world!'; | |
// Add a custom tag entirely, play with this to instantly know how it works: | |
$tags_render_data['my-custom-tag'] = [ | |
'attributes' => [ // The tag attributes. on-* attributes are forbidden. Escaping is not needed. | |
'test' => 'some-exmaple-stuff', | |
'id' => 'mytagid', | |
], | |
'tag' => 'example', // The tag name. | |
'content' => 'Some content', // The tag content. Leave this out to create a void tag. | |
]; | |
return $tags_render_data; | |
}, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment