Webstick.blog logo Wordpress, Design, SEO, Speed blog

Add Meta Tag to WordPress [2024] 💥

Add Meta Tag to WordPress


I'm not going to explain what meta tags are like most sites do. The fact that you landed on this page tells me you already know this. The easiest way to add meta tags to WordPress for most of you is to install a plugin, so let's start with that.


Advertisement

Divi Ad 680px


1. Add meta tag to Wordpress by use of the plugin "Yoast SEO".

The most important meta tags are the meta page title and the meta page description. If these tags are sufficient for you, the best plugin is Yoast SEO which is used by 5 million people.

In your Wordpress back-end go to "Plugins" >> "Add new". Use the search box, typ: "Yoast SEO". Install and activate it. Yoast lets you add title- and description tags for each page and post separately. Just open a post or page and scroll down to where you find this section in Yoast as shown below in the image.

Add Meta Tag to WordPress using Yoast SEO


2. Add meta tag to Wordpress by use of the plugin "Meta Tag Manager".

If you want to add specific meta tags on alle your pages, like tags for language, favicon, indexing for search engines, alternate language tags or any other meta tag it is better to use a different plugin. This tutorial will show you how to add them with the Meta-Tag Manager plugin.

In your Wordpress back-end go to "Plugins" >> "Add new". Use the search box, typ: "Meta Tag Manager". Install and activate it.

Now go to "Settings" >> "Meta Tag Manager" >> "Custom Meta Tags".

You can now create global meta tags and assign them to different sections of your site. Let's suppose you want to add author meta tags for all posts on your site. The settings would be as follows: Tag type= name, Name-value= author, Where to display this tag= Posts. Just just have to select from the options the plugin already gives you (or add your won tag).


Add Meta Tag to WordPress using Meta Tag Manager


Where "General Options" you can decide where the options for meta tags appear, for example on pages. If you just open your pages and scroll down you will find a section of Meta Tag Manager where you can add meta tags only for that particular page. See image below.


Add Meta Tag to WordPress using Meta Tag Manager


The plugin also provides several nice extra options like Schema (structured data) and Site verification for Google, Facebook and more.

3. Add meta tag to Wordpress using the header.php file.

Before you start, you have to be aware that any changes made to your theme will disappear after a theme upgrade. Using this method therefore requires the use of a child theme. Using a child theme changes to header.php will not disappear when upgrading your theme.

Go to "Appearance" >> "Theme File Editor" in the backend of your WP-website. Select first your child-theme, then the file as shown below. The header.php file will have the name "Theme Header". Clicking on it will open it. You can then add your meta tags below the <head> if you want. The tags you place here will all be global, so they will be there on all your pages and post.

Some examples of possible tags to use:
<meta name="rating" content="general" />
<meta name="geo.placename" content="Amsterdam" />
<meta name="geo.position" content="52.367043;4.836026" />


Add Meta Tag to WordPress editing header.php


4. Add meta tag to Wordpress using the functions.php file.

Go to "Appearance" >> "Theme File Editor" in the backend of your WP-website. Select first your child-theme, then the file as shown below. Save the file after adding the PHP code below with your meta tags to the content of functions.php. Where it says "replace_this" of course you enter the right information.


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



Advertisement

Divi Ad 680px



Scroll up