[Preserved version] Summary of unnecessary tags and deletion methods in WordPress head

This time, I will introduce how to clean the HTML that WordPress emits.

WordPress is by default It is designed so that various information is written in the tag, but some tags are not necessary at all.
These unwanted tags are usually invisible to the human eye and may not bother you.
However, by organizing them, in factThere are good things for both SEO and users.

When loading a site, robots such as search engines always read HTML in order from the top.
Unnecessary tags If there are many in the tag, it will be a difficult site for robots to read.
By maintaining the source code and deleting the tags other than the necessary tags, we have summarized the method of deleting unnecessary tags without using a plug-in as much as possible for the source that is easy for the robot to read.

File to edit

Although it is a specific deletion method, it is included in the WordPress theme fileJust add the php code to a file called function.phpIt can be deleted with.

Unnecessary tags for WordPerss

Display unnecessary tags that WordPress spits out genuinely.

Remove meta name ='robots' content ='max-image-preview: large'

meta robots are meta tags for controlling various robots such as search engines.
max-image-preview: large is the instruction "Allow large image preview", and this tag is output by WordPress standard. If you want to customize the contents of meta robots, you don't need this output, so you can safely delete it.

The displayed source code
<meta name='robots' content='max-image-preview:large' />
Code language: HTML, XML (xml)
Source code to be added to function.php
// meta name='robots' content='max-image-preview:large' を非表示にする remove_filter( 'wp_robots', 'wp_robots_max_image_preview_large' );
Code language: JavaScript (javascript)

Remove global-styles-inline-css

With the tag implemented from WordPress 5.9, CSS for the block editor is now output in the head tag.
If you do not use the block editor, you can delete it because it is unnecessary.

The displayed source code
<style id='global-styles-inline-css' type='text/css'> body{--wp--preset--color--black: #000000;--wp--preset--color--cyan-bluish-gray: #abb8c3;--wp--preset--color--white: #ffffff;--wp--preset--color--pale-pink: #f78da7;--wp--preset--color--vivid-red: #cf2e2e;--wp--preset--color--luminous-vivid-orange: #ff6900;--wp--preset--color--luminous-vivid-amber: #fcb900;--wp--preset--color--light-green-cyan: #7bdcb5;--wp--preset--color--vivid-green-cyan: #00d084;--wp--preset--color--pale-cyan-blue: #8ed1fc;--wp--preset--color--vivid-cyan-blue: #0693e3;--wp--preset--color--vivid-purple: #9b51e0;--wp--preset--gradient--vivid-cyan-blue-to-vivid-purple: linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%);--wp--preset--gradient--light-green-cyan-to-vivid-green-cyan: linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%);--wp--preset--gradient--luminous-vivid-amber-to-luminous-vivid-orange: linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%);--wp--preset--gradient--luminous-vivid-orange-to-vivid-red: linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%);--wp--preset--gradient--very-light-gray-to-cyan-bluish-gray: linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%);--wp--preset--gradient--cool-to-warm-spectrum: linear-gradient(135deg,rgb(74,234,220) 0%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(254,248,76) 100%);--wp--preset--gradient--blush-light-purple: linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%);--wp--preset--gradient--blush-bordeaux: linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%);--wp--preset--gradient--luminous-dusk: linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%);--wp--preset--gradient--pale-ocean: linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%);--wp--preset--gradient--electric-grass: linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%);--wp--preset--gradient--midnight: linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%);--wp--preset--duotone--dark-grayscale: url('#wp-duotone-dark-grayscale');--wp--preset--duotone--grayscale: url('#wp-duotone-grayscale');--wp--preset--duotone--purple-yellow: url('#wp-duotone-purple-yellow');--wp--preset--duotone--blue-red: url('#wp-duotone-blue-red');--wp--preset--duotone--midnight: url('#wp-duotone-midnight');--wp--preset--duotone--magenta-yellow: url('#wp-duotone-magenta-yellow');--wp--preset--duotone--purple-green: url('#wp-duotone-purple-green');--wp--preset--duotone--blue-orange: url('#wp-duotone-blue-orange');--wp--preset--font-size--small: 13px;--wp--preset--font-size--medium: 20px;--wp--preset--font-size--large: 36px;--wp--preset--font-size--x-large: 42px;}.has-black-color{color: var(--wp--preset--color--black) !important;}.has-cyan-bluish-gray-color{color: var(--wp--preset--color--cyan-bluish-gray) !important;}.has-white-color{color: var(--wp--preset--color--white) !important;}.has-pale-pink-color{color: var(--wp--preset--color--pale-pink) !important;}.has-vivid-red-color{color: var(--wp--preset--color--vivid-red) !important;}.has-luminous-vivid-orange-color{color: var(--wp--preset--color--luminous-vivid-orange) !important;}.has-luminous-vivid-amber-color{color: var(--wp--preset--color--luminous-vivid-amber) !important;}.has-light-green-cyan-color{color: var(--wp--preset--color--light-green-cyan) !important;}.has-vivid-green-cyan-color{color: var(--wp--preset--color--vivid-green-cyan) !important;}.has-pale-cyan-blue-color{color: var(--wp--preset--color--pale-cyan-blue) !important;}.has-vivid-cyan-blue-color{color: var(--wp--preset--color--vivid-cyan-blue) !important;}.has-vivid-purple-color{color: var(--wp--preset--color--vivid-purple) !important;}.has-black-background-color{background-color: var(--wp--preset--color--black) !important;}.has-cyan-bluish-gray-background-color{background-color: var(--wp--preset--color--cyan-bluish-gray) !important;}.has-white-background-color{background-color: var(--wp--preset--color--white) !important;}.has-pale-pink-background-color{background-color: var(--wp--preset--color--pale-pink) !important;}.has-vivid-red-background-color{background-color: var(--wp--preset--color--vivid-red) !important;}.has-luminous-vivid-orange-background-color{background-color: var(--wp--preset--color--luminous-vivid-orange) !important;}.has-luminous-vivid-amber-background-color{background-color: var(--wp--preset--color--luminous-vivid-amber) !important;}.has-light-green-cyan-background-color{background-color: var(--wp--preset--color--light-green-cyan) !important;}.has-vivid-green-cyan-background-color{background-color: var(--wp--preset--color--vivid-green-cyan) !important;}.has-pale-cyan-blue-background-color{background-color: var(--wp--preset--color--pale-cyan-blue) !important;}.has-vivid-cyan-blue-background-color{background-color: var(--wp--preset--color--vivid-cyan-blue) !important;}.has-vivid-purple-background-color{background-color: var(--wp--preset--color--vivid-purple) !important;}.has-black-border-color{border-color: var(--wp--preset--color--black) !important;}.has-cyan-bluish-gray-border-color{border-color: var(--wp--preset--color--cyan-bluish-gray) !important;}.has-white-border-color{border-color: var(--wp--preset--color--white) !important;}.has-pale-pink-border-color{border-color: var(--wp--preset--color--pale-pink) !important;}.has-vivid-red-border-color{border-color: var(--wp--preset--color--vivid-red) !important;}.has-luminous-vivid-orange-border-color{border-color: var(--wp--preset--color--luminous-vivid-orange) !important;}.has-luminous-vivid-amber-border-color{border-color: var(--wp--preset--color--luminous-vivid-amber) !important;}.has-light-green-cyan-border-color{border-color: var(--wp--preset--color--light-green-cyan) !important;}.has-vivid-green-cyan-border-color{border-color: var(--wp--preset--color--vivid-green-cyan) !important;}.has-pale-cyan-blue-border-color{border-color: var(--wp--preset--color--pale-cyan-blue) !important;}.has-vivid-cyan-blue-border-color{border-color: var(--wp--preset--color--vivid-cyan-blue) !important;}.has-vivid-purple-border-color{border-color: var(--wp--preset--color--vivid-purple) !important;}.has-vivid-cyan-blue-to-vivid-purple-gradient-background{background: var(--wp--preset--gradient--vivid-cyan-blue-to-vivid-purple) !important;}.has-light-green-cyan-to-vivid-green-cyan-gradient-background{background: var(--wp--preset--gradient--light-green-cyan-to-vivid-green-cyan) !important;}.has-luminous-vivid-amber-to-luminous-vivid-orange-gradient-background{background: var(--wp--preset--gradient--luminous-vivid-amber-to-luminous-vivid-orange) !important;}.has-luminous-vivid-orange-to-vivid-red-gradient-background{background: var(--wp--preset--gradient--luminous-vivid-orange-to-vivid-red) !important;}.has-very-light-gray-to-cyan-bluish-gray-gradient-background{background: var(--wp--preset--gradient--very-light-gray-to-cyan-bluish-gray) !important;}.has-cool-to-warm-spectrum-gradient-background{background: var(--wp--preset--gradient--cool-to-warm-spectrum) !important;}.has-blush-light-purple-gradient-background{background: var(--wp--preset--gradient--blush-light-purple) !important;}.has-blush-bordeaux-gradient-background{background: var(--wp--preset--gradient--blush-bordeaux) !important;}.has-luminous-dusk-gradient-background{background: var(--wp--preset--gradient--luminous-dusk) !important;}.has-pale-ocean-gradient-background{background: var(--wp--preset--gradient--pale-ocean) !important;}.has-electric-grass-gradient-background{background: var(--wp--preset--gradient--electric-grass) !important;}.has-midnight-gradient-background{background: var(--wp--preset--gradient--midnight) !important;}.has-small-font-size{font-size: var(--wp--preset--font-size--small) !important;}.has-medium-font-size{font-size: var(--wp--preset--font-size--medium) !important;}.has-large-font-size{font-size: var(--wp--preset--font-size--large) !important;}.has-x-large-font-size{font-size: var(--wp--preset--font-size--x-large) !important;} </style>
Code language: HTML, XML (xml)
Source code to be added to function.php
// global-styles-inline-css を非表示にする add_action( 'wp_enqueue_scripts', 'remove_my_global_styles' ); function remove_my_global_styles() { wp_dequeue_style( 'global-styles' ); }
Code language: JavaScript (javascript)

Removed meta name = ”generator”

A meta generator is a tag that indicates the name of the software used to create the document.
In other words, it is a tag that indicates "This page can be made with WordPress", but I think that it is usually unnecessary, so it will not be a problem to delete it.

The displayed source code
<meta name="generator" content="Wordpress 5.2.2" />
Code language: HTML, XML (xml)
Source code to be added to function.php
// meta name="generator" を非表示にする remove_action('wp_head', 'wp_generator');
Code language: JavaScript (javascript)

EditURI is a tag required when posting an article to WordPress from an external posting tool, but if you do not use an external tool, you should delete it for security reasons.

The displayed source code
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://www.site-domain.com/xmlrpc.php?rsd" />
Code language: HTML, XML (xml)
Source code to be added to function.php
// EditURIを非表示にする remove_action('wp_head', 'rsd_link');
Code language: JavaScript (javascript)

Microsoft's blog update app "Windows Live Writer(Windows Live Writer)A tag for accepting posts from.
If you don't post to WordPress using this app, you don't need it, so you can delete it.

The displayed source code
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://vccw.dev/wp-includes/wlwmanifest.xml" />
Code language: HTML, XML (xml)
Source code to be added to function.php
// wlwmanifestを非表示にする remove_action('wp_head', 'wlwmanifest_link');
Code language: JavaScript (javascript)

WordPress outputs a shortened URL for each page, but if you do not use a shortened URL, it is unnecessary and there is no problem with deleting it.

The displayed source code
<link rel="shortlink" href="https://site-domain.com/?p=1" />
Code language: HTML, XML (xml)
Source code to be added to function.php
// 短縮URLを非表示にする remove_action('wp_head', 'wp_shortlink_wp_head');
Code language: JavaScript (javascript)

Remove JavaScript and CSS for emoji

JavaScript and CSS for pictograms. If you don't use pictograms, you don't need them, so you can delete them.

The displayed source code
<script type="text/javascript"> window._wpemojiSettings = {"baseUrl":"https://s.w.org/images/core/emoji/2.3/72x72/","ext":".png","svgUrl":false,"svgExt":".svg","source":{"concatemoji":"http://vccw.dev/wp-includes/js/wp-emoji-release.min.js?ver=4.8.2"}}; !function(a,b,c){function d(a){var b,c,d,e,f=String.fromCharCode;if(!k||!k.fillText)return!1;switch(k.clearRect(0,0,j.width,j.height),k.textBaseline="top",k.font="600 32px Arial",a){case"flag":return k.fillText(f(55356,56826,55356,56819),0,0),b=j.toDataURL(),k.clearRect(0,0,j.width,j.height),k.fillText(f(55356,56826,8203,55356,56819),0,0),c=j.toDataURL(),b!==c&&(k.clearRect(0,0,j.width,j.height),k.fillText(f(55356,57332,56128,56423,56128,56418,56128,56421,56128,56430,56128,56423,56128,56447),0,0),b=j.toDataURL(),k.clearRect(0,0,j.width,j.height),k.fillText(f(55356,57332,8203,56128,56423,8203,56128,56418,8203,56128,56421,8203,56128,56430,8203,56128,56423,8203,56128,56447),0,0),c=j.toDataURL(),b!==c);case"emoji4":return k.fillText(f(55358,56794,8205,9794,65039),0,0),d=j.toDataURL(),k.clearRect(0,0,j.width,j.height),k.fillText(f(55358,56794,8203,9794,65039),0,0),e=j.toDataURL(),d!==e}return!1}function e(a){var c=b.createElement("script");c.src=a,c.defer=c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var f,g,h,i,j=b.createElement("canvas"),k=j.getContext&&j.getContext("2d");for(i=Array("flag","emoji4"),c.supports={everything:!0,everythingExceptFlag:!0},h=0;h<i.length;h++)c.supports[i[h]]=d(i[h]),c.supports.everything=c.supports.everything&&c.supports[i[h]],"flag"!==i[h]&&(c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&c.supports[i[h]]);c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&!c.supports.flag,c.DOMReady=!1,c.readyCallback=function(){c.DOMReady=!0},c.supports.everything||(g=function(){c.readyCallback()},b.addEventListener?(b.addEventListener("DOMContentLoaded",g,!1),a.addEventListener("load",g,!1)):(a.attachEvent("onload",g),b.attachEvent("onreadystatechange",function(){"complete"===b.readyState&&c.readyCallback()})),f=c.source||{},f.concatemoji?e(f.concatemoji):f.wpemoji&&f.twemoji&&(e(f.twemoji),e(f.wpemoji)))}(window,document,window._wpemojiSettings); </script> <style type="text/css"> img.wp-smiley, img.emoji { display: inline !important; border: none !important; box-shadow: none !important; height: 1em !important; width: 1em !important; margin: 0 .07em !important; vertical-align: -0.1em !important; background: none !important; padding: 0 !important; } </style>
Code language: HTML, XML (xml)
Source code to be added to function.php
// 絵文字用JS・CSSを非表示にする remove_action('wp_head', 'print_emoji_detection_script', 7); remove_action('admin_print_scripts', 'print_emoji_detection_script'); remove_action('wp_print_styles', 'print_emoji_styles'); remove_action('admin_print_styles', 'print_emoji_styles');
Code language: JavaScript (javascript)

Delete RSS feed for posts

This is the part that displays the URL of the RSS feed, but if you do not want to use or want to show the RSS feed, you can delete it.

The displayed source code
<link title="フィード" href="https://www.site-domain.com/" rel="alternate" type="application/rss+xml" />
Code language: HTML, XML (xml)
Source code to be added to function.php
// 投稿の RSS フィードリンクを非表示にする remove_action('wp_head', 'feed_links', 2);
Code language: JavaScript (javascript)

Delete comment feed

This is the part that displays the URL of the comment feed, but if you do not want to use or want to show the comment feed, you can delete it.

The displayed source code
<link title="コメントフィード" href="https://www.site-domain.com/" rel="alternate" type="application/rss+xml" />
Code language: HTML, XML (xml)
Source code to be added to function.php
// コメントフィードを非表示にする remove_action('wp_head', 'feed_links_extra', 3);
Code language: JavaScript (javascript)

Delete the version number given to JavaScript and CSS

WordPress gives JavaScript and CSS the version number of WordPress, the plugin or the script itself.
This is to prevent the browser from using the old cache due to this version number change.
If you don't update JavaScript or CSS frequently, you can remove it.

The displayed source code
<link rel='stylesheet' href='https://site-dimain.com/wp-content/plugins/plugin-name/example.css?ver=1.0.0' media='all'> <script src='https://site-dimain.com/wp-content/themes/theme-name/js/example.js?ver=1.0.0' defer charset='UTF-8'></script>
Code language: HTML, XML (xml)
Source code to be added to function.php
// WordPressのバージョンが付与されたver=〜 を非表示にする function vc_remove_wp_ver_css_js( $src ) { if ( strpos( $src, 'ver=' . get_bloginfo( 'version' ) ) ) $src = remove_query_arg( 'ver', $src ); return $src; } add_filter( 'style_loader_src', 'vc_remove_wp_ver_css_js', 9999 ); add_filter( 'script_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
Code language: PHP (php)

Implemented from WordPress 4.6 "DNS Prefetching(DNS prefetch)It is a description to use.
DNS prefetch is to resolve the name of the external domain DNS in advance, and the read time will be slightly faster.
WordPress prefetches the emoji storage domain, but if you don't use emoji, you don't need it, so delete it.

The displayed source code
<link rel="dns-prefetch" href="//s.w.org" />
Code language: HTML, XML (xml)
Source code to be added to function.php
// dns-prefetchを非表示にする add_filter( 'wp_resource_hints', 'remove_dns_prefetch', 10, 2 ); function remove_dns_prefetch( $hints, $relation_type ) { if ( 'dns-prefetch' === $relation_type ) { return array_diff( wp_dependencies_unique_hosts(), $hints ); } return $hints; }
Code language: PHP (php)

It is a description to call "REST API" implemented from WordPress 4.4.
This is a mechanism that makes it easy for users to extract data from the website by converting the website into an API, which makes it easier to link with external web applications.
If you don't know how to use it, delete it.

The displayed source code
<link rel="https://api.w.org/" href="https://site-dimain.com/wp-json/">
Code language: HTML, XML (xml)
Source code to be added to function.php
// wp versionを非表示にする remove_action('wp_head','rest_output_link_wp_head');
Code language: JavaScript (javascript)

oEmbed removed

oEmbed is a function for embedding external contents such as YouTube and Twitter.
If you don't want to embed external content, delete it.

The displayed source code
<link rel="alternate" type="application/json+oembed" href="https://site-domain.com/wp-json/oembed/1.0/embed?url=http%3A%2F%2Fwww.poroanet.com%2Fblog%2Fwordpress%2F58.html" /> <link rel="alternate" type="text/xml+oembed" href="https://site-domain.com/wp-json/oembed/1.0/embed?url=http%3A%2F%2Fwww.poroanet.com%2Fblog%2Fwordpress%2F58.html&format=xml" />
Code language: HTML, XML (xml)
Source code to be added to function.php
// oEmbedを非表示にする remove_action('wp_head','wp_oembed_add_discovery_links');
Code language: JavaScript (javascript)

Delete rel = ”next” rel = ”prev”

rel = ”next” rel = ”prev” is a mechanism to convey the connection relationship of a series of paginated pages, and Google announced the end of this support in 2019.
This is no longer needed, so you can delete it.

The displayed source code
<link rel="prev" href="https://site-dimain.com/prev-page"> <link rel="next" href="https://site-dimain.com/next-page">
Code language: HTML, XML (xml)
Source code to be added to function.php
//rel="next" rel="prev" を非表示にする remove_action('wp_head','adjacent_posts_rel_link_wp_head');
Code language: JavaScript (javascript)

Remove CSS for Gutenberg

CSS file for Gutenberg added in WordPress 5.
It can be deleted if you switch to the classic editor without using Gutenberg.

The displayed source code
<link rel='stylesheet' id='wp-block-library-css' href='https://site-dimain.com/wp-includes/css/dist/block-library/style.min.css?ver=5.0.3' type='text/css' media='all' />
Code language: HTML, XML (xml)
Source code to be added to function.php
//Gutenberg用CSSを非表示にする function dequeue_plugins_style() { wp_dequeue_style('wp-block-library'); } add_action( 'wp_enqueue_scripts', 'dequeue_plugins_style', 9999);
Code language: JavaScript (javascript)

removal of canonical

It is a display of rel = ”canonical” that is often used in SEO and is necessary for URL normalization, but it can be deleted if you want to delete it when inserting it on the theme side.

The displayed source code
<link rel='canonical' href='https://<meta charset="utf-8">site-dimain.com/hoge/' />
Code language: HTML, XML (xml)
Source code to be added to function.php
//<meta charset="utf-8">canonicalタグの削除 remove_action('wp_head', 'rel_canonical');
Code language: JavaScript (javascript)

Summary for copy and paste

In summary, here is the code to remove all unnecessary tags.

Source code to be added to function.php
// generatorを非表示にする remove_action('wp_head', 'wp_generator'); // EditURIを非表示にする remove_action('wp_head', 'rsd_link'); // wlwmanifestを非表示にする remove_action('wp_head', 'wlwmanifest_link'); // 短縮URLを非表示にする remove_action('wp_head', 'wp_shortlink_wp_head'); // 絵文字用JS・CSSを非表示にする remove_action('wp_head', 'print_emoji_detection_script', 7); remove_action('admin_print_scripts', 'print_emoji_detection_script'); remove_action('wp_print_styles', 'print_emoji_styles'); remove_action('admin_print_styles', 'print_emoji_styles'); // 投稿の RSS フィードリンクを非表示にする remove_action('wp_head', 'feed_links', 2); // コメントフィードを非表示にする remove_action('wp_head', 'feed_links_extra', 3); // WordPressのバージョンが付与されたver=〜 を非表示にする function vc_remove_wp_ver_css_js( $src ) { if ( strpos( $src, 'ver=' . get_bloginfo( 'version' ) ) ) $src = remove_query_arg( 'ver', $src ); return $src; } add_filter( 'style_loader_src', 'vc_remove_wp_ver_css_js', 9999 ); add_filter( 'script_loader_src', 'vc_remove_wp_ver_css_js', 9999 ); // dns-prefetchを非表示にする add_filter( 'wp_resource_hints', 'remove_dns_prefetch', 10, 2 ); function remove_dns_prefetch( $hints, $relation_type ) { if ( 'dns-prefetch' === $relation_type ) { return array_diff( wp_dependencies_unique_hosts(), $hints ); } return $hints; } // wp versionを非表示にする remove_action('wp_head','rest_output_link_wp_head'); // oEmbedを非表示にする remove_action('wp_head','wp_oembed_add_discovery_links'); //rel="next" rel="prev" を非表示にする remove_action('wp_head','adjacent_posts_rel_link_wp_head'); //Gutenberg用CSSを非表示にする function dequeue_plugins_style() { wp_dequeue_style('wp-block-library'); } add_action( 'wp_enqueue_scripts', 'dequeue_plugins_style', 9999);
Code language: PHP (php)

Unnecessary tags derived from plugins

In addition to the unnecessary tags output by WordPress itself, the plugin may output unnecessary tags.

The following is an example, but I will introduce it.

Remove rel = ”next” rel = ”prev” inserted by Yoast SEO

rel = ”next” rel = ”prev” is a tag that represents pagination (pagination), but since it is an element that Google has not seen, it can basically be deleted.

Source code to be added to function.php
// Yoast の prev を表示させない add_filter( 'wpseo_prev_rel_link', '__return_false' ); // Yoast の next を表示させない add_filter( 'wpseo_next_rel_link', '__return_false' );
Code language: JavaScript (javascript)

Removed rel = ”canonical” inserted by Yoast SEO

AboveThis is the Yoast version of the deletion of rel = ”canonical”.

Similarly, if you insert it on the theme side, it will be a double description, so delete it.

Source code to be added to function.php
// Yoast の canonical を表示させない add_filter( 'wpseo_canonical', '__return_false' );
Code language: JavaScript (javascript)

Remove og tags inserted in Yoast SEO

It is a deletion code of various og tags inserted by Yoast.

Source code to be added to function.php
// Yoast の og:type を表示させない add_filter( 'wpseo_opengraph_type', '__return_false' ); <meta charset="utf-8">// Yoast の og:url を表示させない add_filter( 'wpseo_opengraph_url', '__return_false' ); <meta charset="utf-8">// Yoast の og:site_name を表示させない add_filter( 'wpseo_opengraph_site_name', '__return_false' ); // Yoastの og:locale <meta charset="utf-8">を表示させない function remove_locale_presenter( $presenters ) { return array_map( function( $presenter ) { if ( ! $presenter instanceof YoastWPSEOPresentersOpen_GraphLocale_Presenter ) { return $presenter; } }, $presenters ); } add_action( 'wpseo_frontend_presenters', 'remove_locale_presenter' );
Code language: PHP (php)

Remove og tags that are automatically inserted by Jetpack

The removal code for the og tag that Jetpack inserts.

Source code to be added to function.php
// Jetpackで自動挿入されるogタグを非表示にする remove_action('wp_head','jetpack_og_tags');
Code language: JavaScript (javascript)

Remove Google Fonts loaded by Elementor

Stops loading Google Fonts loaded by Elementor, a page builder plugin.
If you don't use Google Fonts, you should delete it.
Also, if you want to directly load font data installed by yourself, such as subsetting, or implement "webfontloader" for asynchronous loading, you need to delete Google Fonts inserted by Elementor.

Source code to be added to function.php
// Elemtorが読み込むGoogle Fontsの削除 add_filter( 'elementor/frontend/print_google_fonts', '__return_false' );
Code language: JavaScript (javascript)

Remove Font Awesome loaded by Elementor

It also stops loading Font Awesome, which Elementor loads.

Source code to be added to function.php
// ElemtorのFont Awesome読み込みを停止 add_action( 'elementor/frontend/after_register_styles',function() { foreach( [ 'solid', 'regular', 'brands' ] as $style ) { wp_deregister_style( 'elementor-icons-fa-' . $style ); } }, 20 );;
Code language: PHP (php)

Remove WPML generator

This tag is automatically inserted when you are using WPML, a multilingual plugin for WordPress, but it is basically unnecessary because it is just a tag that says "I'm using WPML".

Source code to be added to function.php
// WPML generatorを非表示にする global $sitepress; remove_action( 'wp_head', array( $sitepress, 'meta_generator_tag' ) );
Code language: PHP (php)

Removed revslider generator

This tag is automatically inserted when using the slider plug-in Slider Revolution, but it is basically unnecessary because it is just a tag that says "I'm using Slider Revolution".

Source code to be added to function.php
// revslider generatorを非表示にする function remove_revslider_meta_tag() { return ''; } add_filter( 'revslider_meta_generator', 'remove_revslider_meta_tag' );
Code language: JavaScript (javascript)

bonus

Mechanism of tags output in tags

In WordPress, it is a rule to write a function called wp_head () in header.php. It is a mechanism that can output the tag to the wp_head () description part in the tag.
Related files such as CSS and JS used in plugins are also output through wp_head ().

So, if you delete wp_head (), the extra tags will disappear, but the necessary tags will also disappear, so don't delete wp_head ().

see you.

Kazuhiro Nakamura
Kazuhiro Nakamura
Representative of Cocorograph Inc. 13 years of SEO history, more than 970 sites with countermeasures. We provide SUO, an upward compatible service of SEO that optimizes not only search engines but also search users. SEO / SUO's original report tool, Sachiko Report Developer. Book "The latest common sense of SEO taught by professionals in the field"
Kazuhiro Nakamura
Kazuhiro Nakamura
Representative of Cocorograph Inc. 13 years of SEO history, more than 970 sites with countermeasures. We provide SUO, an upward compatible service of SEO that optimizes not only search engines but also search users. SEO / SUO's original report tool, Sachiko Report Developer. Book "The latest common sense of SEO taught by professionals in the field"