Skip to content

Instantly share code, notes, and snippets.

@tenman
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenman/5b50d03be2d5a3e5f56e to your computer and use it in GitHub Desktop.
Save tenman/5b50d03be2d5a3e5f56e to your computer and use it in GitHub Desktop.
Add description and keyword
<?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