Created
August 29, 2011 19:19
-
-
Save nacin/1179160 to your computer and use it in GitHub Desktop.
Replacement for wp_title()?
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 | |
// 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