Create a gist now

Instantly share code, notes, and snippets.

「初心者でもプラグインを使わずにtitle,meta keyword,descriptionを投稿ごとに変える」の修正版(ブログ用)
<?php if ( $post->my_description ): //meta descriptionの設定 ?>
<meta name="description" content="<?php echo esc_attr( $post->my_description ); ?>" />
<?php else: ?>
<meta name="description" content="<?php bloginfo('description'); ?>" />
<?php endif; ?>
<?php if ( $post->my_keywords ): //meta keywordsの設定 ?>
<meta name="keywords" content="<?php echo esc_attr( $post->my_keywords ); ?>" />
<?php else: ?>
<meta name="keywords" content="デフォルトワード,デフォルトワード,デフォルトワード" />
<?php endif; ?>
<?php if ( $post->my_title ): //titleタグの設定 ?>
<title><?php echo esc_html( $post->my_title ); ?></title>
<?php else: ?>
<title><?php wp_title( '|', true, 'right' ); ?><?php bloginfo('name'); ?></title>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment