My wordpress render in the head tag lots of unneeded script or css files, I tried to fix this by editing my head.php page but the theme I was using (zerif) use wp_head function to include all the scripts files.

I tried to see where I could edit the output of the function I took a look to the wordpresss documentation

They said that every theme specifies this with do_action("wp_head") .

I searched for that on my theme code but I didn't find anything, so how can I edit this ? Should I hard code everything without using wp_head() ?

1 Answer 1


You can remove some default WP links of the head by using remove_action(). For example:

// Removes the wlwmanifest link
remove_action( 'wp_head', 'wlwmanifest_link' );
// Removes the RSD link
remove_action( 'wp_head', 'rsd_link' );
// Removes the WP shortlink
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
// Removes the canonical links
remove_action( 'wp_head', 'rel_canonical' );
// Removes the links to the extra feeds such as category feeds
remove_action( 'wp_head', 'feed_links_extra', 3 ); 
// Removes links to the general feeds: Post and Comment Feed
remove_action( 'wp_head', 'feed_links', 2 ); 
// Removes the index link
remove_action( 'wp_head', 'index_rel_link' ); 
// Removes the prev link
remove_action( 'wp_head', 'parent_post_rel_link' ); 
// Removes the start link
remove_action( 'wp_head', 'start_post_rel_link' ); 
// Removes the relational links for the posts adjacent to the current post
remove_action( 'wp_head', 'adjacent_posts_rel_link' );
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' );
// Removes the WordPress version i.e. -
remove_action( 'wp_head', 'wp_generator' );

To remove the emoji support (CSS and Javascript):

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' );

You must use them in your functions.php file.

To edit the files enqueued by your theme (zerif) you will need to edit the functions.php file, as well. For example, you will find something like this:

wp_enqueue_style( 'style', get_stylesheet_uri() );
wp_enqueue_style( 'shortcodes', get_template_directory_uri() . '/css/shortcodes.css' );
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.css' );
wp_enqueue_script( 'jquery' );

If you don't find it in your functions.php, it's because some themes divide the functions.php content among several files, normally included into a specific folder with the name inc, include or framework. That's easy to know: these files must be loaded into your functions.php. For example:

locate_template( 'inc/widgets.php', true, true );
locate_template( 'inc/sidebars.php', true, true );
locate_template( 'inc/breadcrumbs.php', true, true );
locate_template( 'inc/whatever.php', true, true );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.