Add custom meta tags to HTML head via functions.php

There are a few cases where you need to add your own Meta Tags in your header. For example to verify that you are the website owner.

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" />

There are WordPress plugins available to achieve the same. But it can be done without a plugin if you follow these simple steps below:

1. Navigate to wp-content > themes folder and select your child theme

2. Open functions.php

3. Add the following PHP code with your meta tags and save the file

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

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.