New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp_title Support #8

Closed
bueltge opened this Issue Nov 3, 2014 · 0 comments

Comments

1 participant
@bueltge
Owner

bueltge commented Nov 3, 2014

Changes for WP 4.1 at wp_title()

Add support in inc/setup.php

/**
 * Let WordPress manage the document title. 
 * By adding theme support, we declare that this theme does not use a 
 * hard-coded <title> tag in the document head, and expect WordPress to 
 * provide it for us. 
 */ 
add_theme_support( 'title-tag' );

Remove Markup and title in templates, like single.php

<title><?php wp_title( '|', true, 'right' ); ?></title>

Backwards compatibility

To enable support in existing themes without breaking backwards compatibility, theme authors can check if the callback function exists, and add a shiv in case it does not:

if ( ! function_exists( '_wp_render_title_tag' ) ) :
function theme_slug_render_title() {
    echo '<title>' . wp_title( '|', false, 'right' ) . "</title>\n";
}
add_action( 'wp_head', 'theme_slug_render_title' );
endif;

This would also be the place to optionally add a filter to enhance the document title, along the lines of what recent default themes have been doing.

Background

https://make.wordpress.org/core/2014/10/29/title-tags-in-4-1/

@bueltge bueltge added the Feature label Nov 3, 2014

@bueltge bueltge closed this in e8aa06f Nov 3, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment