How to clean headers in WordPress?
WordPress has by default inserts a lot of unnecessary code into the header of the HTML source code, sometimes we don’t need to use it.
I will talk about the components that should be removed to clean the header
These include:
- Really simple discovery link (rsd_link)
- WordPress version (wp_generator) : wordpress version <meta name =” generator ” content =” WordPress 5.7.2 ” />
- RSS feed links (feed_links and feed_links_extra)
- Link to index page (index_rel_link)
- wlwmanifest.xml (wlwmanifest_link)
- Random post link (start_post_rel_link)
- Parent post link (parent_post_rel_link)
- Next and previous post links (adjacent_posts_rel_link)
- WP shortlink (wp_shortlink)
To remove all the above code in the WordPress header, you just need to add the following code in the functions.php file of the theme or child theme you are using:
remove_action('wp_head', 'rsd_link'); // remove really simple discovery link
remove_action('wp_head', 'wp_generator'); // remove wordpress version
remove_action('wp_head', 'feed_links', 2); // remove rss feed links (make sure you add them in yourself if youre using feedblitz or an rss service)
remove_action('wp_head', 'feed_links_extra', 3); // removes all extra rss feed links
remove_action('wp_head', 'index_rel_link'); // remove link to index page
remove_action('wp_head', 'wlwmanifest_link'); // remove wlwmanifest.xml (needed to support windows live writer)
remove_action('wp_head', 'start_post_rel_link', 10, 0); // remove random post link
remove_action('wp_head', 'parent_post_rel_link', 10, 0); // remove parent post link
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0); // remove the next and previous post links
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0); // Remove shortlink<div>
<span>1</span><span>2</span><span>3</span><span>4</span><span>5</span><span>6</span><span>7</span><span>8</span><span>9</span><span>10</span><span>11</span><span>12</span><span>13</span><span>14</span><span>15</span><span>16</span><span>17</span><span>18</span>
</div>
Epilogue
So I have shared cleaning headers in WordPress a very simple trick that makes your site more optimized.
If you find it interesting, you can follow the wordpress tips section to know more new knowledge.
Follow fanpage to receive the latest posts: Group
Wish you have interesting and interesting knowledge about wordpress!

