LoginSignup
0
0

More than 5 years have passed since last update.

WordPressのオリジナルテーマにtitleタグを表示させる

Last updated at Posted at 2018-09-03

はじめに

ワードプレスに初めから用意されているテーマを使う場合は、管理画面よりタイトルを記入すれば自動的に表示されます。

今回はオリジナルでhtmlやcssを作成したものを、ワードプレスに組み込む(自身でテーマを作る)場合を想定しています。

手順

1. ワードプレス管理画面メニューの「外観」→「テーマの編集」より、
テーマのための関数(function.php)を選択して下さい。

2. function.phpに以下のコードを記述し、ファイルを更新して下さい。

<?php
function my_setup_theme() {
    add_theme_support( 'title-tag' );
}
add_action( 'after_setup_theme', 'my_setup_theme' );

3. テーマヘッダー(header.php)を選択して下さい。
4. 以下の<?php wp_head(); ?>の記述がなければ<head></head>の間に記述して更新して下さい。

<?php wp_head(); ?>

以上でワードプレスのオリジナルテーマにもタイトルタグが自動的に表示されるようになります。

以下を参考にさせていただきました。
http://smallville.jp/wordpress/194

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