How to Add Custom Meta Tags to HTML Head in WordPress via functions.php

Custom meta tags are an important part of a website’s SEO strategy. By adding custom meta tags to the HTML head of a WordPress website, website owners can control how their website is described and displayed in search engine results. Custom meta tags can also be used to add specific information to a website’s head, such as social media descriptions and other important information.

In this tutorial, we will show you how to add custom meta tags to the HTML head of a WordPress website via the functions.php file.

Meta tags look like this:

<meta name="key" content="value" />
<meta name="keywords" content="keyword1, keyword2" />
<meta name="description" content="this is the description of this page" />
<meta name="facebook-domain-verification" content="abcdefghijklmnopqrstuvwxyz" />

To get started, you will need to access the functions.php file of your WordPress theme. You can do this by logging into your website’s backend and navigating to Appearance > Theme File Editor > Your child theme > functions.php

Once you have accessed the functions.php file, you will need to add the following code:

* Add custom Meta Tag to header. 
function custom_header_metadata() {
	echo '<meta name="your-meta-name" content="your-meta-content">';
add_action( 'wp_head', 'custom_header_metadata' );

Replace "your-meta-name" and "your-meta-content" with the desired name and content for your custom meta tag. You can add as many custom meta tags as you need by repeating the code and changing the name and content accordingly.

Once you have added the custom meta tags, save the functions.php file and upload it to your website.

In conclusion, adding custom meta tags to the HTML head of a WordPress website via the functions.php file is a simple and effective way to improve your website’s SEO and control how your website is displayed in search engine results. By following the steps outlined in this tutorial, you can easily add custom meta tags to your WordPress website and start optimizing your website for search engines.

Thats it!

Support 🐶

If you found this article helpful, got a question or spotted an error/typo... Do well to leave your feedback in the comment section or help spread it by sharing this article. If you're feeling generous (and I hope you do) you can definitely help me by getting me a cup of coffee ☕.

You may like these too!

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *