How to Add Meta Tags in WordPress: 3 Simple Methods to Try

Jigar Shah
Jigar Shah
how to add meta tags in wordpress

Meta tags play a vital role in optimizing your website for search engines, making them a crucial part of your SEO strategy. These small pieces of HTML code provide search engines with key information about your content, helping your site rank higher in search results. This is why SEO experts always recommend adding meta tags to enhance the visibility and relevance of your pages.

If you’re using WordPress, adding meta tags is simple, and you can either use a plugin or do it manually. In this guide, we’ll show you both methods so you can choose the one that suits your needs.

What are Meta Tags?

Meta tags are essential elements of HTML code that provide valuable information about a web page’s content to search engines, web browsers, and other online services. These hidden snippets of data play a crucial role in optimizing a WordPress website for search engine visibility. Plus, they can help with social media sharing and rendering of the pages on different devices.

By offering insights into a page’s title, description, and other attributes, meta tags help improve how a website is perceived and interacted with in the digital landscape. They are a fundamental tool for web developers and content creators striving to enhance their online presence and user experience.

Now, there are a few different types of meta tags available for WordPress websites.

  • Title Tag (<title>): The title tag in WordPress is generated based on the title you provide when creating a post or page. It is essential for on-page SEO, as it represents the title of your content in search engine results and browser tabs. You can customize the title tag using SEO plugins or themes that support SEO features.
  • Meta Description Tag (<meta name= “description”>): The meta description tag allows you to specify a brief description of your post or page’s content. It is often displayed in the SERPs below the title and can influence whether users click on your link. You can customize the meta description using SEO plugins or themes.
  • Meta Robots Tag (<meta name= “robots”>): The meta robots tag is crucial for instructing search engine crawlers on how to handle your web page. It can control whether a page should be indexed or not, whether links should be followed or not, and other important indexing instructions.
  • Open Graph Protocol Tags: These tags are used to control how your content appears when shared on social media platforms like Facebook. They include tags such as og:title, og:description, og:image, and og:url. WordPress SEO plugins often provide options to set these tags for individual posts and pages.
  • Canonical Tag (<link rel= “canonical”>): The canonical tag helps address duplicate content issues by specifying the preferred URL for a particular post or page. It can be essential if you have multiple URLs containing similar content.

Here are common examples of meta tags offered by WordPress itself:

<meta name="resource-type" content="document" />
<meta http-equiv="content-type" content="text/html; charset=US-ASCII" />
<meta http-equiv="content-language" content="en-us" />
<meta name="author" content="Harriet Smith" />
<meta name="contact" content="harrietsmith@harrietsmith.us" />
<meta name= "copyright" content= "Copyright (c)1997-2004 
Harriet Smith. All Rights Reserved."/>
<meta name="description" content="Story about my dog 
giving birth to puppies."/>
<meta name= "keywords" content= "stories, tales, harriet, smith, 
harriet smith, storytelling, day, life, dog, birth, puppies, happy"/>

While meta tags are not the sole determinants of a web page’s ranking, they are still valuable tools for optimizing your website’s visibility in search results and ensuring that search engines understand your content correctly.

Want to ensure the best SEO optimization practices for your website?

How to Add Meta Tags in WordPress?

WordPress is known for its flexibility, and it shows when you’re trying to add a meta description or tag. The platform offers multiple methods and tools to cater to users with different levels of technical expertise and requirements. There are 3 ways to add meta tags in WordPress, and we’ll see the step-by-step process for each of them.

Method 1: Adding Meta Tags in WordPress Manually

When we talk about manually adding the meta tags in WordPress, the process is performed using ‘header.php’, a file located in the WordPress root directory

Since you’re going to be making changes to your theme files, I recommend you create a backup of your WordPress website. So, it would be possible to restore your site in case something goes wrong. And use a child theme to make sure you don’t lose your modifications during theme updates.

Step 1: Log into your WordPress admin dashboard

Step 2: Navigate to “Appearance” and select “Theme File Editor”.

how to add meta tags in wordpress-method1-step2

Step 3: Now, from a list of theme files, locate “header.php” and open it with a text or code editor.

how to add meta tags in wordpress-method1-step3

Step 4: Inside the ‘header.php’ file, locate the ‘<head>’ section. This section typically contains the opening ‘<head>’ tag and various other meta tags and links.

Step 5: Add your custom meta tags between the <head> and </head> tags. For example, to add an Open Graph meta tag for an image, you can use the following code:

<meta property="og:image" content="https://example.com/your-image.jpg">

Replace “https://example.com/your-image.jpg” with the actual URL of your image and adjust the properties and content as needed for other meta tags.

Step 6 (Optional): Add a Conditional Meta Tag for Post Views
Want to display a unique meta description for individual posts versus archive or homepage views? You can achieve this using a simple conditional query.

First, go to Admin > Settings > General and set your site’s meta description in the Tagline field.

Next, insert the following code into your header.php file:

<meta name="description" content="<?php 
if ( is_single() ) {
    single_post_title('', true); 
} else {
    bloginfo('name'); echo ' - '; bloginfo('description');
} ?>" />

This code ensures that single-post pages show the post title as the meta description, while other pages display the site name and tagline instead.

Step 7: After adding the desired meta tags, click the “Update File” button to save your changes to the ‘header.php’ file.

how to add meta tags in wordpress-method1-step6

Now, to ensure that your custom meta tags are correctly added to your website, visit the best browser for WordPress development. Right-click on the website and select “Inspect” to view the page’s source code. There, you can confirm that the meta tags are present in the ‘<head>’ section.

If you’re using a WordPress caching plugin like W3 Total Cache or WP Super Cache to clear the WordPress cache so that changes take effect immediately.

Manually editing theme files like header.php requires a basic understanding of core WordPress development. Mistakes in the code can break your website. So, if you don’t have the necessary skills and experience, I suggest you opt for our WordPress development services.

Method 2: Using functions.php

This step is almost similar to the first one, except for the PHP code functions and WordPress hooks used to insert the meta tags into your website.

Again, if you are going with functions.php to add meta tags in WordPress, make sure you take a backup of your website. And, of course, use a child theme for more customization, flexibility, and security in case of updates.

Let’s start the process of adding meta tags in WordPress using functions.php.

Step 1: Access the WordPress admin panel.

Step 2: Navigate to “Appearance” and select “Theme File Editor”.

how to add meta tags in wordpress-method1-step2

Step 3: From the file list on the right-hand side, locate and select “functions.php”.

how to add meta tags in wordpress-method2-step3

Step 4: Open the “functions.php” file with a text or code editor, and add your custom meta tags. 

function custom_dynamic_meta_description() {
    global $post;
    if ( is_singular() ) {
        $post_content = strip_tags( $post->post_content );
        $post_content = strip_shortcodes( $post_content );
        $post_content = str_replace( array("\n", "\r", "\t"), ' ', $post_content );
        $post_content = mb_substr( $post_content, 0, 300, 'utf8' );
        echo '<meta name="description" content="' . esc_attr( $post_content ) . '" />' . "\n";
    }
    if ( is_home() ) {
        echo '<meta name="description" content="' . esc_attr( get_bloginfo( "description" ) ) . '" />' . "\n";
    }
    if ( is_category() ) {
        $category_description = strip_tags( category_description() );
        echo '<meta name="description" content="' . esc_attr( $category_description ) . '" />' . "\n";
    }
}
add_action( 'wp_head', 'custom_dynamic_meta_description' );

Step 5: After adding the desired meta tags, click the “Update File” button to save your changes to the ‘functions.php’ file.

Step 6: To ensure that your custom meta tags are correctly added to your WordPress site, visit the pages where you added them.

Step 7: If using a caching plugin, make sure to clear the cache on your WordPress website to ensure that your changes take effect immediately.

Now, as the name suggests, ‘functions.php’ directly impacts the way your WordPress website functions. So, if you don’t have the necessary coding skills and experience, consult with dedicated WordPress experts. Or you can opt for an SEO or meta tag plugin to make the process a little easier.

Method 3: Adding the WordPress Meta Tags Through Plugins

Plugins are like the Swiss Army Knives that equip you with a range of skills and functionalities to tackle various tasks effectively. That includes the ability to add meta tags in WordPress websites. 

SEO plugins like Rank Math, Yoast SEO, and more help simplify adding and managing meta tags, making them user-friendly for WordPress users. Or you can use a dedicated plugin like Meta Tag Manager.

Option 1: Using Meta Tag Manager

Here, we’ll see how to add meta tags in WordPress using the plugin “Meta Tag Manager”.

Step 1: Log into the WordPress admin.

Step 2: Navigate to “Plugins” and click “Add New”.

Step 3: Search for “Meta Tag Manager.”, click “Install Now”, and then “Activate”.

Step 4: After activating the plugin, you’ll find a new menu item called “Meta Tag Manager” in your WordPress dashboard. Click on the WordPress plugin’s setting to configure them.

In the settings screen of this plugin, you’ll see five sections: Custom Meta Tags, General Options, Open Graph (for open graph tags), Structured Data (Schema), and Site Verification, along with “Pro Features!”.

how to add meta tags in wordpress-method3-step4

Step 5: In the “Custom Meta Tags” section, there lies an option to “Add Meta Tag”. Click on it.

That will open up a bunch of settings to add meta tags on WordPress websites.

Tag Type: The tag type specifies the purpose or category of the meta tag you’re adding. It helps you choose the right type of meta tag for your specific use case. Some common tag types include:

  • meta (Generic meta tag)
  • title (Title tag)
  • link (Link tag)
  • script (Script tag)
  • style (Style tag)
  • og (Open Graph tags for social media)
  • twitter (Twitter Card tags)
  • jsonld (JSON-LD structured data)

Name Attribute: The name attribute, also known as the property attribute for Open Graph tags, specifies the name or property associated with the meta tag. This attribute helps search engines, social media platforms, and browsers understand the purpose of the tag. For example:

  • name= “description” for the meta description tag.
  • property= “og:title” for the Open Graph title tag.
  • name= “keywords” for the meta keywords tag (though it’s not commonly used anymore).

Value Attribute: The value attribute contains the actual content or value of the meta tag. This is where you provide the specific information you want to convey through the tag. For example:

  • content= “Your meta description text here” for the meta description tag.
  • content= “Your website title” for the title tag.
  • content= “https://example.com/your-image.jpg” for the Open Graph image tag. 

These attributes work together to define the purpose and content of each meta tag you add using the “Meta Tag Manager” plugin. Plus, you have to specify “Where to display this tag”.

By specifying the tag type, name (or property), and content, you can control how your website’s information is presented to search engines, social media platforms, and other online services.

This plugin lets you add as many meta tags in your WordPress website as you want. After customizing the settings according to your requirements, click on “Save Changes”. That will add meta tags to WordPress. 

Option 2: Using Yoast SEO

Another widely-used option is Yoast SEO, a plugin that integrates directly with your post/page editor. Once installed and activated, scroll below your content editor to find the Yoast SEO meta box.

Yoast SEO meta box

Here’s what you can configure:

  • Focus Keyphrase: Enter the keyword you’re targeting; Yoast provides feedback on how well your content is optimized for it.
  • SEO Title: Customize your page’s title for search engines. Keep it under 60 characters and include the keyphrase.
  • Slug: Edit the URL slug to match the topic clearly.
  • Meta Description: Write a compelling summary (under 160 characters) that shows up in search snippets.

Yoast also shows a live Google snippet preview and gives SEO readability scores, making it a beginner-friendly yet powerful option.

Option 3: Using All in One SEO (AIO SEO)

All in One SEO (AIO SEO) offers a similar but streamlined experience. After activating the plugin, you’ll find the AIO SEO settings under each post/page editor.

AIO SEO meta box

In the AIO SEO meta box, you can configure:

  • Post Title: Your search-optimized title.
  • Meta Description: Short, targeted summary for SERPs.
  • Focus Keyword: The main keyword for your content.

And more of the details according to your needs.

AIO SEO meta box configuration

AIO SEO allows users to also set default metadata for homepage, archives, and taxonomies from its global settings. It’s particularly suited for those who prefer clean interfaces without overwhelming optimization suggestions.

All three plugins serve different needs. Yoast SEO and AIO SEO focus on ease of use and keyword-based optimization, while Meta Tag Manager gives more manual control over the actual HTML tags. Choose based on your SEO goals and preferred workflow.

FAQs on How to Add Meta Tags in WordPress

Can I add custom meta tags to WordPress pages or posts?

Yes, you can add custom meta tags to WordPress pages or posts using plugins like Yoast SEO or by manually editing your theme’s template files. Custom meta tags allow for more precise control over metadata for specific purposes.

Are meta keywords tags still important in WordPress for SEO?

No, meta keywords tags are no longer considered important for SEO in WordPress. Major search engines like Google do not use them as a ranking factor. Focus on meta titles, meta descriptions, and relevant content instead.

Is it possible to add meta tags to specific pages or posts in WordPress and not to all pages?

Yes, you can add meta tags to specific pages or posts in WordPress. You have control over meta tags on a per-page or per-post basis, allowing you to customize them individually to match the content and purpose of each page or post.

Conclusion

Adding meta tags in WordPress might seem minor, but it’s a powerful tool for getting noticed by the right audience. By customizing your titles and descriptions, you’re giving search engines clear, specific information that can drive relevant traffic straight to your site.

Whether you use a plugin or do it manually, remember that each meta tag is an opportunity to connect with users before they even land on your page. Take control of your metadata, keep it relevant to your content, and you’ll see it pay off in higher click-through rates and better engagement.

If you need further optimizations to improve your site’s visibility on search engines, hire our SEO experts.

Make your website stand out from the competition!
author
Jigar Shah is the Founder of WPWeb Infotech - a leading Web Development Company in India, USA. Being the founder of the company, he takes care of business development activities and handles the execution of the projects. He is Enthusiastic about producing quality content on challenging technical subjects.