Last active
August 29, 2015 14:01
-
-
Save tenman/5b50d03be2d5a3e5f56e to your computer and use it in GitHub Desktop.
Add description and keyword
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 | |
/* サイトキーワード と概要 */ | |
add_filter( 'the_generator', 'generator2description' ); | |
function generator2description( $content ) { | |
global $post; | |
$result = ''; | |
if ( is_front_page() || is_home() ) { | |
$result .= $content . "\n"; | |
$result .= '<meta name="keywords" content="WordPress,Theme,Raindrops,ワードプレス,テーマ,レインドロップス,日本語対応,公式テーマ,Responsive" />' . "\n"; | |
$result .= '<meta name="description" content="このサイトは、ワードプレス(WordPress)日本語対応公式レスポンシブテーマ 「レインドロップス(Raindrops)」の公式サイトです。最新のレインドロップスの情報を提供しています。" />' . "\n"; | |
return $result; | |
} else { | |
if ( !is_sticky() && is_singular() ) { | |
$keywords = get_post_meta( $post->ID, 'keyword', true ); | |
if ( !empty( $keyword ) ) { | |
$result .= '<meta name="keywords" content="' . esc_attr( $keywords ) . '" />' . "\n"; | |
} | |
$description = get_post_meta( $post->ID, 'description', true ); | |
if ( !empty( $description ) ) { | |
$result .= '<meta name="description" content="' . esc_attr( $description ) . '" />' . "\n"; | |
} | |
return $content . $result; | |
} | |
return $content; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment