Skip to content

Instantly share code, notes, and snippets.

@landjonathan
Created November 10, 2022 08:15
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 landjonathan/46120246a2fa286c65727f85f8e96914 to your computer and use it in GitHub Desktop.
Save landjonathan/46120246a2fa286c65727f85f8e96914 to your computer and use it in GitHub Desktop.
Add shortcodes to Wordpress titles
// core WP titles
add_filter('the_title', 'do_shortcode');
add_filter('wp_title', 'do_shortcode');
// add to Yoast generated titles
// page title
add_filter('wpseo_title', 'do_shortcode');
// schema -> webpage title
add_filter('wpseo_schema_webpage', function ($data) {
$data['name'] = apply_shortcodes($data['name']);
return $data;
});
// og:title
add_filter('wpseo_opengraph_title', 'do_shortcode');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment