Last active
December 11, 2015 01:59
-
-
Save RyoSugimoto/4527365 to your computer and use it in GitHub Desktop.
WordPressでの<title>要素の記述例。
This file contains hidden or 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
<title><?php | |
global $page, $paged; | |
// Import global variables about pages | |
wp_title('|', true, 'right'); | |
// Get and display the title of the current page | |
bloginfo('name'); | |
// Get the title of your blog | |
$site_description = get_bloginfo('description', 'display'); | |
// Get the description, with quotes fixed | |
if ($site_description && (is_home() || is_front_page())){ | |
echo "|$site_description"; | |
} | |
// When the current page is home or front, display the description | |
if ($paged >= 2 || $page >= 2){ | |
echo '|'.sprintf(__('Page %s'), max($paged, $page)); | |
} | |
// Display the number of the current page, | |
// if the page is an archive or a multi-paged article | |
?></title> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment