Skip to content

Instantly share code, notes, and snippets.

@sybrew
Last active November 22, 2023 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sybrew/272b746296114cd93c3320e9544a1618 to your computer and use it in GitHub Desktop.
Save sybrew/272b746296114cd93c3320e9544a1618 to your computer and use it in GitHub Desktop.
TSF meta render data filter
<?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