LoginSignup
0
0

More than 3 years have passed since last update.

【WordPress】メタ情報を直接headerに書く方法

Last updated at Posted at 2019-12-17

なにこれ?

プラグインでSEO設定しちゃうことが多いので忘れないようにメモ。
全部head内に記載。

タイトル

管理画面の設定>一般で設定された「サイトのタイトル」を表示
<title><?php bloginfo('name'); ?></title>

TOPページ以外は、「そのページのタイトル|ブログタイトル」の方がいい。

TOP以外
<title><?php wp_title(''); ?><?php bloginfo('name'); ?></title>

ディスクリプション(サイトの説明)

管理画面の設定>一般で設定された「キャッチフレーズ」を表示
<meta name="description" content="<?php bloginfo('description'); ?>">
ページのタイトルをディスクリプションに入れたい時
<meta name="description" content="<?php wp_title(''); ?><?php bloginfo('description'); ?>">

ページのタイトルをディスクリプションに入れたい時はこんな感じ。

キーワード

キーワードを設定
<meta name="keywords" content="キーワード1,キーワード2,キーワード3,キーワード4">

キーワードについてやSEOについては諸説あるけども。
とりあえず、コンマ区切りで複数設定可。

ページ名をキーワードに入れたい時
<meta name="keywords" content="<?php wp_title(''); ?>,キーワード1,キーワード2,キーワード3,キーワード4">

もちろん、キーワードにそのページのタイトルも入れることも出来る。

リンク

Codex

bloginfo:サイトの情報を表示させる関数です。
wp title:現在のページのタイトルを表示または取得します。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0