0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

WordPressのwp_head()の余計なmetaを削除する

Posted at

ワードプレスのテーマtwentytwentyoneを基盤に、wp_head() 挿入時に自動生成される余計なmeta情報を削除する実装を行ったので、備忘録的にこの記事を残す。

環境情報

PHP:version 7.3.12
WordPress:version 5.5.3
WPテーマ:twentytwentyone

作業

functions.php
// WPのバージョンを削除
remove_action( 'wp_head', 'wp_generator' );

remove_action( 'wp_head', 'rsd_link' );

remove_action( 'wp_head', 'wlwmanifest_link' );

remove_action( 'wp_head', 'index_rel_link' );

remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );

remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );

remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
// metaタイトルを削除
remove_action( 'wp_head', '_wp_render_title_tag', 1);
// 投稿、コメントのフィードに関するlinkタグを削除
remove_action( 'wp_head', 'feed_links', 2 );
// カテゴリごと、タグごと、投稿者ごと、検索のフィードに関するlinkタグを削除
remove_action( 'wp_head', 'feed_links_extra', 3 );

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?