Skip to content

Instantly share code, notes, and snippets.

@nacin
Created August 29, 2011 19:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nacin/1179160 to your computer and use it in GitHub Desktop.
Save nacin/1179160 to your computer and use it in GitHub Desktop.
Replacement for wp_title()?
<?php
// In a theme:
add_action( 'after_setup_theme', function() {
add_theme_support( 'title-tag', array( 'option' => true ) );
} );
// In core:
add_action( 'wp_head', '_wp_render_title_tag' );
function _wp_render_title_tag() {
if ( ! current_theme_supports( 'title-tag' ) )
return;
if ( null !== $pre = apply_filters( 'pre_wp_title_tag', null ) ) {
echo '<title>' . $pre . "<title>\n";
return;
}
$options = get_theme_support( 'title-tag' );
$options = $options[0];
// do something special to generate $title
$title = apply_filters( 'wp_title_tag', $title, $options );
echo '<title>' . $title . "</title>\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment