How to edit, change wp_head () in WordPress?

How to edit, change wp_head () in WordPress?

How exactly to edit, change wp_head () in WordPress?

What is wp_head();? It is s a WordPress built-in function.

The content you see in your head tag “wp_head();”, is located inside the functions.php file from the current theme that you are using.

How to edit, change wp_head ()?

Open functions.php from the current WordPress theme that you are using and add this code at the bottom.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'start_post_rel_link');
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'adjacent_posts_rel_link');
remove_action('wp_head', 'shortlink');
 
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
remove_action('wp_head', 'wp_shortlink_wp_head');
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
 
remove_action( 'wp_head', 'feed_links_extra', 3 ); // Display the links to the extra feeds such as category feeds
remove_action( 'wp_head', 'feed_links', 2 );

This code will remove all the unnecessary files that are currently located in your wp_head ().
You can add them to your footer area if you need any of them.
Check the code in the browser from your header, add them in a txt file and then place them in your footer area if needed.

Also, if you see bootstrap or jquery files in your WordPress header, wp_head (), and you want to remove those files so you can add them in the footer, look for “global $wp_scripts;” or something similar, or just do a search for “bootstrap” as keyword.


The location of jquery or bootstrap files can also be changed from functions.php, from your current theme.

You will see some results. Start to delete the code, bootstrap, jquery, and refresh the source code in the browser.

Most of the time, it is necessary to edit, change wp_head () in WordPress in order to optimize your theme, depending on various website speed benchmarks like GTmetrix or even Google.

By placing some of the code in the footer, rather than leaving it in the header, the website will load faster as the unnecessary code is loaded lastly, from the footer.

Add a comment: