Skip to content

How to Add Meta Tags in WordPress: Plugin and Manual Methods

Flat code tag icon beside the title How to Add Meta Tags in WordPress

Learning how to add meta tags in WordPress takes about 10 minutes using an SEO plugin, or 20 to 30 minutes if you go the manual route through your theme files. Either way, the task is well within reach for beginners and developers alike.

Most guides skip one important detail before you start: that WordPress already generates some meta tags on its own. If you add those manually on top, you end up with duplicates in your <head> section, and that can break your social share previews entirely. Knowing exactly which tags you need to add (and which ones to leave alone) saves you from that headache.

This guide covers three methods for adding meta tags in WordPress: an SEO plugin, header.php and functions.php. We checked every tag against Google’s Search Central docs and the WordPress code reference in October 2026. A verification checklist at the end confirms your tags work.

What Are Meta Tags in WordPress?

Meta tags in WordPress page source added by Rank Math

Meta tags are HTML snippets that sit inside the <head> section of your web page. Visitors never see them, but search engines and social platforms read them to understand your content and decide how to display it. Google publishes the list of meta tags it supports.

Meta tags and WordPress post tags are completely different things. Post tags are labels you assign to organize your content on the site. Meta tags live in the HTML source code and are invisible to readers. If you want to understand how WordPress post tags relate to SEO, WordPress Tags and SEO is worth reading separately.

The Meta Tags That Matter for WordPress On-Page SEO

  • Title tag: The clickable headline shown in search results. WordPress generates a basic version from your post title and site name. SEO plugins let you customize it per page. Google uses it as a main source for the title link in results.
  • Meta description: The short summary (about 155 characters) is shown below the title in search results. It does not directly affect rankings, but it heavily influences whether people click your result. WordPress does not generate meta descriptions by default. If you skip this, Google writes one for you, and Google’s version is usually a random excerpt from your page.
  • Meta robots tag: Tells search engines whether to index a page and whether to follow its links. Common instructions are noindex (keep this page out of search results) and nofollow (don’t pass link equity through this page’s links). WordPress offers a site-wide option under Settings > Reading. Per-page control needs a plugin.
  • Open Graph tags: Control how your content looks when someone shares it on Facebook, LinkedIn or other social platforms. They follow the Open Graph protocol. Without them, social platforms guess what to display. They usually guess wrong. To pick the image shown in previews, see what image WordPress shows on preview.
  • Twitter Card tags: The same idea as Open Graph, but specific to X (formerly Twitter). Most SEO plugins handle both together.

Now here’s the part most tutorials skip entirely.

What WordPress Already Generates and What You Need to Add

Meta TagGenerated by WordPress?Action Needed
Title tagYes (basic version)Customize with an SEO plugin
Meta descriptionNoAdd with a plugin or manually
Canonical tagYes on single posts and pages (since WordPress 2.9)No action needed
Viewport tagYes (via your theme)No action needed
Robots tagPartial (site-wide only)Add per-page control with a plugin
Open Graph tagsNoAdd with a plugin or manually
Twitter Card tagsNoAdd with a plugin or manually
Meta keywordsN/ASkip entirely. Google confirmed in 2009 that it does not use them for ranking

The canonical tag is the one that trips people up most. WordPress has printed it on single posts and pages since version 2.9. Adding it by hand or through a second plugin creates duplicates. The same goes for the viewport tag. Your theme already outputs it.

How to Add Meta Tags in WordPress Using an SEO Plugin

For most WordPress sites, an SEO plugin is the right choice. You get per-page control over titles, descriptions, Open Graph data, and robots instructions, all without touching a single line of code. The plugin also generates sensible defaults for pages you haven’t optimized yet.

The three most widely used options are Yoast SEO, Rank Math, and All in One SEO (AIOSEO). The core workflow is similar across all three. Here’s how they compare:

FeatureYoast SEO (Free)Rank Math (Free)AIOSEO (Free)
Focus keywords per post151
Open Graph tagsYesYesYes
Twitter Card tagsYesYesYes
Robots (noindex/nofollow)YesYesYes
Schema markup typesBasic18+ typesBasic
Snippet previewYesYesYes
Redirect managerNo (Premium)YesNo (Pro)
Google Search Console integrationNoYesNo

Rank Math offers the most in its free version. Yoast SEO has the largest community with 10+ million active installations on WordPress.org as of October 2026. If you’re unsure which to pick, Yoast is the safer default for beginners because of the sheer volume of tutorials available.

The steps below use Yoast SEO. If you’re using Rank Math or AIOSEO, the same fields exist under slightly different labels in their respective meta boxes.

How to Add a WordPress Meta Description and Title Tag with Yoast SEO

  1. Go to Plugins > Add Plugin in your WordPress dashboard.
    Add Plugin item under Plugins in the WordPress dashboard menu
  2. Search for Yoast SEO, click Install Now and then Activate.
    Yoast SEO plugin card with the Install Now button in WordPress
  3. Run through the Yoast configuration wizard. It sets your site-wide defaults such as site name, site representation and logo.
    First-time configuration screen in Yoast SEO with the heading outlined
  4. Open the post or page you want to optimize in the block editor.
    WordPress block editor with a post title outlined
  5. Open the Yoast SEO panel in the editor sidebar.
    Yoast SEO icon and sidebar panel in the WordPress block editor
  6. Enter your focus keyphrase. This is the keyword you want this page to rank for.
    Focus keyphrase field in the Yoast SEO sidebar of the post editor
  7. Click the SEO title field to customize your title tag. Yoast uses variables like %%title%% and %%sitename%% that auto-populate. Mix these with custom text if needed.
    SEO title field with variable chips in the Yoast Search appearance window
  8. Write your meta description in the description field. Yoast shows a character counter and a live snippet preview. Keep it under 155 characters and include your target keyword. Google cuts by pixels rather than characters, so preview where your snippet gets cut before you publish.
    Meta description field with a live Google preview in the Yoast Search appearance window
  9. Save or publish the post.
    Block editor top bar with the Save button highlighted

Repeat this process for every post and page you want to optimize. Pages you haven’t touched will use the site-wide defaults you set in the configuration wizard.

Worth knowing: Yoast also adds robots meta tags automatically based on your WordPress reading settings and per-page toggles. You don’t need to add those manually.

How to Add Open Graph Tags with an SEO Plugin

Open Graph tags in WordPress control what title, description, and image appear when someone shares your page on social media. Without them, Facebook and LinkedIn pull whatever they find first, often a sidebar image or the first sentence of body text.

In Yoast SEO, Open Graph tags are enabled by default. To check and customize them:

  1. Open the post in the block editor.
    WordPress block editor with the Hello world post and the List View panel open
  2. In the Yoast SEO meta box, click the Social tab (the share icon). Yoast SEO Premium unlocks this tab.
    Yoast SEO Social tab with the social share preview and an Unlock with Yoast SEO Premium button
  3. Add a custom Facebook title, description, and image if you want them to differ from your SEO title and meta description.
    Yoast SEO Social tab with the Social image and Social title and Social description fields
  4. Repeat for the X (Twitter) tab if needed.
    Yoast X card settings in the Social tab
  5. Save the post.
    Block editor top bar with the Save button highlighted

Old Open Graph tags hard-coded in header.php by a previous developer cause trouble here. With an SEO plugin active, both sets of tags appear in <head>. Platforms may read the outdated set and show the wrong image. If your social previews look wrong after setting up Yoast, check your source code for duplicate og:title or og:description tags.

Test one WooCommerce product page in the Sharing Debugger as well as a blog post. Product pages use a different template. Their tags can differ from your posts.

How to Add Meta Tags in WordPress Manually (Without a Plugin)

The manual approach makes sense in two situations: you’re building a lean site and want to avoid plugin overhead, or you’re a developer maintaining a custom WordPress build where SEO plugin output conflicts with existing code.

For everyone else, the plugin method above is faster and safer. But if manual is your path, here are both options.

Method 1: Editing header.php (Site-Wide, Static Tags)

This method adds the same meta tags across your entire site. It takes about five minutes, but there’s a real trade-off.

The trade-off: Every time your theme updates, your changes to header.php are overwritten. You lose everything unless you’re working inside a child theme in WordPress. If you don’t have a child theme set up, do that first or use WPCode (covered below) instead.

Steps:

  1. Go to Appearance > Theme File Editor (Tools > Theme File Editor on block themes) in your WordPress dashboard.
    Theme File Editor under Appearance in the WordPress dashboard menu
  2. In the right-hand file list, select header.php under your active theme (or child theme).
    WordPress Theme File Editor with header.php open and the theme file list on the right
  3. Find the closing </head> tag in the code.
    Meta tags added above the closing head tag in header.php in the Theme File Editor
  4. Paste your meta tags just above </head>:
<meta name="description" content="Your site description here." />
<meta property="og:title" content="Your Site Name" />
<meta property="og:description" content="Your site description here." />
<meta property="og:image" content="https://yoursite.com/your-image.jpg" />
<meta property="og:url" content="https://yoursite.com" />
<meta property="og:type" content="website" />
  1. Click Update File.
    Update File button under the Theme File Editor
  2. Open your site in a browser, right-click the page, and select View Page Source. Search for <meta to confirm your tags appear in the <head> section.
    Page source of devdiggers.com with the title and Open Graph meta tags in the head section

The limitation: These tags are static. Every page on your site shows the same description and the same Open Graph image. That’s fine for a small brochure site, but it breaks down fast on any site with multiple pages or posts that need unique descriptions.

Method 2: Using functions.php and the wp_head Hook (Dynamic, Per-Page)

This is the better manual method for blogs and any WordPress build where pages need different meta descriptions. It uses the wp_head action hook in functions.php. The hook inserts tags based on which page is loading.

  1. In Appearance > Theme File Editor, select Theme Functions (functions.php) in the right-hand file list under your child theme.
    WordPress Theme File Editor with functions.php open
  2. Add this to your child theme’s functions.php file:
function devdiggers_dynamic_meta_tags() {
    global $post;

    if ( is_singular() ) {
        // Use excerpt if available, otherwise pull from content
        if ( has_excerpt( $post->ID ) ) {
            $description = get_the_excerpt( $post->ID );
        } else {
            $description = wp_trim_words( strip_shortcodes( $post->post_content ), 30, '...' );
        }
        $description = esc_attr( wp_strip_all_tags( $description ) );
        $title       = esc_attr( get_the_title( $post->ID ) );
        $url         = esc_url( get_permalink( $post->ID ) );
        $image       = esc_url( get_the_post_thumbnail_url( $post->ID, 'large' ) );

        echo '<meta name="description" content="' . $description . '" />' . "\n";
        echo '<meta property="og:title" content="' . $title . '" />' . "\n";
        echo '<meta property="og:description" content="' . $description . '" />' . "\n";
        echo '<meta property="og:url" content="' . $url . '" />' . "\n";
        echo '<meta property="og:type" content="article" />' . "\n";

        if ( $image ) {
            echo '<meta property="og:image" content="' . $image . '" />' . "\n";
        }

    } elseif ( is_home() || is_front_page() ) {
        $description = esc_attr( get_bloginfo( 'description' ) );
        $title       = esc_attr( get_bloginfo( 'name' ) );

        echo '<meta name="description" content="' . $description . '" />' . "\n";
        echo '<meta property="og:title" content="' . $title . '" />' . "\n";
        echo '<meta property="og:description" content="' . $description . '" />' . "\n";
        echo '<meta property="og:type" content="website" />' . "\n";
    }
}
add_action( 'wp_head', 'devdiggers_dynamic_meta_tags' );
  • Critical note before you add this: Do not run this code alongside an SEO plugin like Yoast SEO or Rank Math that already outputs meta descriptions and Open Graph tags. Both sets of tags will appear in your <head>. Platforms may then read the wrong one. If you’re switching from a plugin to manual code, deactivate the plugin first. If you’re going the other direction, remove this function before activating the plugin.
  • For OG images: Aim for 1200×630 pixels. This size renders well across Facebook, LinkedIn, and X without cropping or scaling issues.

If you would rather not edit functions.php, use the WPCode plugin. Install it from Plugins > Add Plugin and search for WPCode. Activate it and go to Code Snippets > Add Snippet. Paste the function above as a PHP snippet and save. WPCode keeps your code separate from your theme files. It survives theme updates without a child theme.

What Meta Tags Does WordPress Already Add by Default?

WordPress adds a title tag in most themes, a canonical link on single posts and pages and a robots meta tag. Your theme adds the viewport tag. WordPress adds no meta description, Open Graph or Twitter Card tags. Check your page source before you add anything.

Before you add anything, check your page source and look at what’s already in your <head>. WordPress and your theme generate several tags automatically. Adding them again creates duplicates, and duplicate meta tags confuse bots and break social sharing.

Here’s what you can safely leave alone:

  • Canonical tag: WordPress has printed a canonical tag on single posts and pages since version 2.9. You only need to change it for a specific duplicate content case. One example is a product page reachable from several URLs. Our guide to adding a canonical tag in WordPress covers that case.
  • Viewport tag: Your theme outputs this. It tells mobile browsers how to scale the page. Leave it alone.
  • Basic title tag: WordPress generates a title from your post title and site name. An SEO plugin improves and customizes it, but you don’t need to add a title tag from scratch.

What you do need to add: meta description, Open Graph tags, Twitter Card tags and per-page robots instructions. None of those is generated by default.

Skipping this check is how pages end up with two canonical tags or duplicate og:image entries.

Tags printed twice also happen with titles, and you can find and fix duplicate title tags with a page source check.

How to Verify Your Meta Tags Are Working

Four tools that check meta tags: View Page Source and Search Console and two social preview tools

Verify your meta tags by checking the page source first and then the tools that read them. View Page Source shows what WordPress prints. Search Console shows what Google sees. The Facebook Sharing Debugger and LinkedIn Post Inspector show the social preview each platform will build.

Use these four tools to check your work after setup:

  1. View Page Source: Open your site in a browser, right-click the page and select View Page Source. Press Ctrl+F (or Cmd+F on Mac) and search for <meta. Scan through the results. You’re checking that your description, Open Graph tags and any custom tags appear once each and never twice or more.
  2. Google Search Console: Go to Search Console > URL Inspection, paste your page URL and run the inspection. Click View crawled page to see the HTML Google fetched, including your meta tags. If Google is ignoring your meta description and writing its own, the description may be too generic or mismatched to the page content.
  3. Facebook Sharing Debugger: Go to developers.facebook.com/tools/debug and paste your page URL. This shows exactly what Facebook sees: the title, description, and image for the social preview. If you’ve made changes recently, click Scrape Again to force a cache refresh. This is the most reliable way to confirm Open Graph tags are working.
  4. metatags.io or LinkedIn Post Inspector: metatags.io gives you a visual preview of how your page will appear across multiple platforms at once. LinkedIn Post Inspector (linkedin.com/post-inspector) is useful specifically if you’re sharing content on LinkedIn and the preview looks wrong. LinkedIn caches aggressively. Always use the Inspector after making changes.

Conclusion

Adding meta tags in WordPress comes down to three decisions. First, pick the tags you need. WordPress already prints several. Next, pick a method: a plugin for most people and manual code for developers. Then verify the tags are live and correct.

The plugin method is faster and safer for most sites. The functions.php method gives you more control but requires care around duplicates. Either way, run your pages through the Facebook Sharing Debugger and View Source after setup. That five-minute check saves hours of troubleshooting later.

For anything more complex, such as custom post types, WooCommerce product schemas, or multi-site configurations, the WordPress development services team at DevDiggers builds and maintains these setups regularly.

Frequently Asked Questions (FAQs)

Q1. Does WordPress automatically add meta tags?

WordPress adds a basic title tag and a canonical tag on single posts and pages. Your theme adds the viewport tag. WordPress does not add meta descriptions, Open Graph tags or Twitter Card tags. For those, you need an SEO plugin or manual code in your theme files.

Q2. Do meta tags affect Google rankings in WordPress?

Google uses your title tag as a main source for the title link in search results. A clear title that matches the page helps searchers pick your result. Google uses the meta description for snippets only when it describes the page better than the page text. A good description can still earn more clicks. Meta robots tags affect indexing directly because a noindex tag removes a page from search results entirely. Get that one wrong, and you’ll wonder why your pages disappeared from Google.

Q3. What is the difference between meta tags and WordPress post tags?

Meta tags are HTML code in your page’s <head> section that is invisible to visitors but read by search engines and social platforms. WordPress post tags are labels you assign to organize blog content on your site. They serve entirely different purposes and are completely unrelated to each other.

Q4. Do I need both Yoast SEO and manual meta tags in header.php?

No. Running both simultaneously creates duplicate tags in your <head> section. Duplicate meta descriptions and Open Graph tags cause social platforms to pull incorrect data and confuse search bots. Pick one method and stick with it. If you switch, remove the old tags before activating the new setup.

Q5. How do I add meta tags to a specific page only in WordPress?

An SEO plugin is the cleanest way. Both Yoast SEO and Rank Math show a meta box below every post and page editor where you can set a unique title, description, and social tags per page. For the manual functions.php method, use WordPress conditional tags like is_page( 42 ) or is_singular( ‘post’ ) to target specific pages.

Q6. Can I add meta tags in WordPress without touching any code?

Yes. Install an SEO plugin like Yoast SEO or Rank Math, run the setup wizard, and fill in the meta fields on each post or page. No code editing required. If you need to insert custom meta tags beyond what a standard SEO plugin handles, WPCode lets you add PHP snippets safely without editing theme files directly.

Q7. Why is Google showing a different meta description than the one I wrote?

Google builds most snippets from the page text. It shows your meta description only when that gives searchers a more accurate summary. Write a unique description that sums up the specific page in 120 to 155 characters. Include your target keyword where it reads naturally.

Q8. What image size should I use for Open Graph tags in WordPress?

Use 1200×630 pixels. This renders well on Facebook, LinkedIn, and X without cropping. Go below 600 pixels wide, and Facebook may ignore the image entirely and show a text-only preview. Set your featured image to this size for posts, and configure a backup OG image in your SEO plugin settings for pages without a featured image.

Rishi Yadav
Rishi Yadav

Rishi Yadav is a content writer at DevDiggers who covers WooCommerce store management, WordPress performance and security. He works through each topic in a test environment before writing about it. His guides focus on the steps and settings that matter and skip the ones that sound good on paper.

Leave a Reply

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