'How to change HTML structure inside WP <head>

I'm cleaning up some HTML code, and I would like to have a HTML structure that looks like this:

<!DOCTYPE html>
<html >
<head>
<title>...</title>
<meta name="description" content="..." />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> ...

So basically I want 'title' and 'meta description' to appear right after 'head' tag. Site is running Wordpress , so I already looked into general-template.php -file but didn’t find output for ‘meta description’.

Do I need to install a plugin for meta description (Yoast for example) and then change the location of the wp_head() ? Or do I need to edit the wp_head() function somehow?



Solution 1:[1]

edit you themes header.php, simple :) make sure <?php wp_head();?> is beneath all of that if it exists...

Solution 2:[2]

There are a lot cleaning head solutons like addding hooks to clean most of the worpress default functionality(RSD, RSS links etc.). Try out following hooks in theme functions.php:

/*remove actions to clean wp_head*/
remove_action('wp_head', 'wlwmanifest_link'); // remove wlwmanifest.xml (needed to support windows live writer)
remove_action('wp_head', 'wp_generator'); // remove wordpress version
remove_action( 'wp_head', 'wp_resource_hints', 2 );//remove dns prefech
remove_action('wp_head', 'rsd_link'); // remove really simple discovery link
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0 ); // remove shortlink

remove_action( 'wp_head', 'print_emoji_detection_script', 7 );  // remove emojis
remove_action( 'wp_print_styles', 'print_emoji_styles' );   // remove emojis

remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); // remove the / and previous post links

remove_action('wp_head', 'feed_links', 2); // remove rss feed links
remove_action('wp_head', 'feed_links_extra', 3); // removes all extra rss feed links

remove_action( 'wp_head', 'rest_output_link_wp_head', 10 ); // remove the REST API link
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); // remove oEmbed discovery links
remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); // remove the REST API link from HTTP Headers

remove_action( 'wp_head', 'wp_oembed_add_host_js' ); // remove oEmbed-specific javascript from front-end / back-end

remove_action('rest_api_init', 'wp_oembed_register_route'); // remove the oEmbed REST API route
remove_filter('oembed_dataparse', 'wp_filter_oembed_result', 10); // don't filter oEmbed results

You may also wrap this snippet into functions to make it work after_theme_setup or init

Other tags like charset and http-equiv attributes can be insluded after wp_head(); action in header.php. Also take a look at the wp-includes template folder files to locate wp_head() action and remove/comment unnecessary actions

Solution 3:[3]

Just make sure <?php wp_head();?> is between your head tags. That way when you install Yoast SEO or any plugin, the proper content will be inserted there.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 danyo
Solution 2 ?????? ?????
Solution 3