WordPress.org

Make WordPress Core

Changeset 30097


Ignore:
Timestamp:
10/29/2014 09:55:24 PM (6 years ago)
Author:
iandstewart
Message:

Twenty Fifteen: leading the way with support for title-tag

Props obenland, fixes #30146.

Location:
trunk/src/wp-content/themes/twentyfifteen
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyfifteen/functions.php

    r30072 r30097  
    5757    // Add default posts and comments RSS feed links to head.
    5858    add_theme_support( 'automatic-feed-links' );
     59
     60    /*
     61     * Let WordPress manage the document title.
     62     * By adding theme support, we declare that this theme does not use a
     63     * hard-coded <title> tag in the document head, and expect WordPress to
     64     * provide it for us.
     65     */
     66    add_theme_support( 'title-tag' );
    5967
    6068    /*
     
    227235
    228236/**
    229  * Filters wp_title to print a neat <title> tag based on what is being viewed.
    230  *
    231  * @param string $title Default title text for current view.
    232  * @param string $sep Optional separator.
    233  * @return string The filtered title.
    234  */
    235 function twentyfifteen_wp_title( $title, $sep ) {
    236     if ( is_feed() ) {
    237         return $title;
    238     }
    239 
    240     global $page, $paged;
    241 
    242     // Add the blog name
    243     $title .= get_bloginfo( 'name', 'display' );
    244 
    245     // Add the blog description for the home/front page.
    246     $site_description = get_bloginfo( 'description', 'display' );
    247     if ( $site_description && ( is_home() || is_front_page() ) ) {
    248         $title .= " $sep $site_description";
    249     }
    250 
    251     // Add a page number if necessary:
    252     if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
    253         $title .= " $sep " . sprintf( __( 'Page %s', 'twentyfifteen' ), max( $paged, $page ) );
    254     }
    255 
    256     return $title;
    257 }
    258 add_filter( 'wp_title', 'twentyfifteen_wp_title', 10, 2 );
    259 
    260 /**
    261237 * Add featured image as background image to post navs.
    262238 *
  • trunk/src/wp-content/themes/twentyfifteen/header.php

    r30072 r30097  
    1414    <meta charset="<?php bloginfo( 'charset' ); ?>">
    1515    <meta name="viewport" content="width=device-width, initial-scale=1">
    16     <title><?php wp_title( '|', true, 'right' ); ?></title>
    1716    <link rel="profile" href="http://gmpg.org/xfn/11">
    1817    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
Note: See TracChangeset for help on using the changeset viewer.