1. Home
  2. Blog
  3. Tutorials
Tutorials

How to Add Meta Keywords in WordPress Without Plugin (With Code)

Learn how to add meta keywords in WordPress without a plugin using a child theme and safe PHP code, plus why Google ignores the keywords meta tag.

How to Add Meta Keywords in WordPress Without Plugin (With Code)
Summarize this article with AIOpens your AI assistant in a new tab
ChatGPT Claude Perplexity Google AI

You can add a meta-keywords tag to WordPress without installing an SEO plugin. The simplest maintainable approach is to output the tag through the wp_head action in a child theme, where WordPress can place it inside the page’s HTML head. You should know one important limitation before editing anything: Google does not use the keywords meta tag for indexing or rankings.

That does not make the HTML tag impossible or automatically harmful. A private site search system, an old internal workflow, or a specific third-party service may still request it. But if the goal is better Google visibility, optimizing titles, descriptions, content, and internal links will generally be more useful. This guide explains how to add meta keywords in WordPress without plugin, safely and with realistic expectations.

What are meta keywords in WordPress?

Meta keywords are an HTML metadata element written in the document’s <head> section. The basic syntax is <meta name="keywords" content="wordpress, tutorial, website tips">. The content attribute contains a comma-separated set of words or phrases that describe the page.

Unlike a heading or paragraph, this tag is not normally visible to someone reading the page. It appears in the HTML source that browsers and automated systems can inspect. WordPress does not require this tag for a page to work, and modern search optimization practices do not depend on it.

Do not confuse meta keywords with a page’s focus keyphrase field in an SEO plugin. A focus keyphrase is often an editorial input used by the plugin to analyze copy. It does not necessarily create an HTML keywords tag, and the two concepts serve different purposes.

Does Google use the meta-keywords tag for SEO?

No. Google Search Central explicitly states that the <meta name="keywords"> tag has no effect on Google indexing or ranking. Adding dozens of keywords will not make a WordPress page rank for those phrases, and there is no useful target keyword density for this metadata field.

The situation is different for some other metadata. A descriptive title helps convey a page’s topic, and Google may use a meta description to generate a search snippet when it is relevant. A robots meta tag can provide indexing instructions, while canonical information helps communicate the preferred version of duplicate or similar URLs.

Those tags are not interchangeable. If your purpose is SEO, ask which outcome you want: a clearer result snippet, more helpful content, correct indexability, or a technical integration that specifically demands a keywords field. The answer determines which change is worth making.

Before editing code: protect your WordPress website

A misplaced PHP character can cause an error on a live site. Back up the files and database, and prepare access to SFTP or the hosting file manager in case you need to reverse the change. Testing in staging is sensible, especially when your website handles customer purchases or leads.

Use a child theme for customization where possible. Editing a commercial parent theme’s functions.php directly is risky because an update can overwrite your work. A child theme keeps your site-specific code separate from many parent-theme updates, although it still needs maintenance and compatibility checks.

You also need permission to edit files on your hosting environment. Some managed WordPress providers disable the built-in theme file editor for security reasons. That is normal; access through the provider’s supported file-management or deployment process is often preferable.

Method 1: Add site-wide meta keywords with functions.php

If a system genuinely requires a site-wide keywords tag, the WordPress wp_head hook is a clean way to print it without changing a theme template. Open the active child theme’s functions.php using a safe file editor. If the file already starts with <?php, do not add another PHP opening tag inside it.

Add the following code at the end of the PHP file, outside any existing function. Replace the example words with terms that actually describe your site. This example escapes the attribute value before it is printed into the HTML.

function site_custom_meta_keywords() {
    $keywords = 'wordpress tutorials, website management, web development';
    echo '<meta name="keywords" content="' . esc_attr( $keywords ) . '">' . "\n";
}
add_action( 'wp_head', 'site_custom_meta_keywords' );

Save the file and open the public homepage. View page source and search for name="keywords". You should see one tag inside the head section. If it is missing, verify that the child theme is active and that its wp_head action runs through a properly coded theme.

This method outputs the same keywords on every page, so it is not ideal when a third-party service expects unique page-level metadata. It is, however, simple to maintain for a genuinely site-wide requirement. Do not repeat irrelevant phrases across all pages merely because the snippet makes it easy.

Method 2: Output different keywords for selected pages

A conditional version is useful when a specific integration needs metadata for a handful of pages. WordPress conditionals such as is_front_page() and is_page() let you select the appropriate value. Keep the logic limited and easy to audit rather than inventing a complex keyword generator.

Here is a compact example that outputs separate values for the homepage and a page whose slug is services. It does not generate a tag on other pages. The output is again escaped using a WordPress function.

function site_page_specific_meta_keywords() {
    if ( is_front_page() ) {
        $keywords = 'web design, wordpress services';
    } elseif ( is_page( 'services' ) ) {
        $keywords = 'website maintenance, wordpress support';
    } else {
        return;
    }
    echo '<meta name="keywords" content="' . esc_attr( $keywords ) . '">' . "\n";
}
add_action( 'wp_head', 'site_page_specific_meta_keywords' );

Use this method instead of, not alongside, the site-wide example. If you enable both, selected pages may receive two keywords tags. Multiple overlapping outputs create confusion for systems that expect a single value, and they make troubleshooting needlessly difficult.

As your site grows, hard-coding hundreds of page IDs or slugs becomes cumbersome. If a third-party application demands large-scale page-specific metadata, consider an appropriately designed custom-fields workflow or developer-built functionality. Avoid creating a permanent maintenance burden for a tag that Google ignores.

Method 3: Add a static HTML tag directly in a theme template

A traditional classic theme often has a header.php template containing the document’s head section. You can place a static meta tag before the closing </head> line, provided you understand the file’s structure and use an appropriate child-theme override. The tag itself is ordinary HTML, not PHP.

<meta name="keywords" content="wordpress guides, website tutorials">

This route is less flexible than a hook and may not apply to block themes, which can construct their output differently. Copying a whole parent template into a child theme also creates ongoing compatibility responsibilities. For most people who need a lightweight code-based solution, wp_head is the better starting point.

Never paste the HTML tag into the visible content editor expecting it to become page metadata. A normal paragraph or custom HTML block is part of the page body, and adding a tag there is not the same as placing it in the document head.

Can you add meta keywords without touching a theme file?

If the website already includes an approved site-specific snippets system, an existing custom functionality module, or a deployment workflow that supports WordPress hooks, you may be able to add code there without editing a theme. That does not mean installing another plugin is required. The exact options depend on the site you manage.

However, if you specifically want to use only native WordPress files, the child-theme functions.php method is straightforward. Whichever route you choose, keep a record of where the snippet lives. Duplicate snippets are surprisingly easy to introduce when different administrators work on the same website.

How to verify the meta tag correctly

Checking the content editor is not enough. Open the live page in a browser and use View Page Source. Search for the exact text name="keywords" and confirm that the content attribute contains your intended words. Look for duplicate tags and verify that the tag appears inside the document head rather than the body.

Check the homepage and at least one inner page. If you used page-specific conditions, inspect a page that should have a tag and another that should not. Page caches may continue serving older HTML, so clear only the relevant cache if your changes are not immediately visible.

You can also use browser developer tools to inspect the generated DOM. Just remember that the DOM can be modified after load by JavaScript; the initial HTML source is often the clearest place to confirm PHP-generated tags.

Common problems when adding meta keywords manually

The keywords tag is not showing

Check that you saved the correct functions.php and that the currently active theme loads it. Confirm you did not accidentally add the snippet to an inactive child theme or a parent theme on a different staging environment. Also verify that wp_head() is present in the theme’s head template where appropriate.

A caching layer can hide changes even when the code is running correctly. Purge the appropriate cache and reload the source. If the snippet still fails, check your server’s PHP error log rather than guessing at the cause.

A fatal error appears after editing PHP

Restore the last working file using SFTP, your host’s file manager, or a verified backup. A missing semicolon, stray quotation mark, or extra opening tag is enough to break a PHP file. Avoid applying more experimental changes until you understand the error.

This is why editing directly inside the live theme file editor can be uncomfortable: the rollback path may be harder to access when the dashboard is unavailable. A controlled deployment or staging test reduces the risk.

The site contains duplicate keywords tags

Search the source and review your child theme, parent theme, and installed SEO tools for existing output. Disable the redundant snippet rather than trying to make two tags agree. Having a single source of truth is easier for future maintainers.

Google rankings did not improve

That is expected. Google does not use the keywords meta tag as a ranking factor. If organic traffic is the goal, check indexing, title relevance, page content, internal links, technical health, and whether the page answers its audience’s search intent.

What should you optimize instead of meta keywords?

Start with a descriptive HTML title and one clear page heading. Write a unique introduction that answers the primary question, then structure details under meaningful subheadings. Make sure important content is accessible without requiring complex interactions or hidden panels.

Use accurate meta descriptions to summarize pages for potential search snippets. Add relevant internal links from other pages on your website, and improve images with appropriate file sizes and descriptive alt text. Keep crawl controls and canonical tags consistent so search engines are not receiving mixed instructions.

If your site contains a large amount of stale or overlapping content, review whether consolidation or improvement would help more than another metadata field. This kind of work takes longer than pasting code, but it aligns far better with what readers and modern search systems need.

Frequently asked questions

Are meta keywords still useful in WordPress?

They can serve niche integrations that explicitly read the tag, but they do not help with Google Search rankings. Only add them when you have a specific requirement that justifies the maintenance.

Can I add meta keywords in WordPress without an SEO plugin?

Yes. A small PHP function attached to wp_head can output the tag from a child theme. Verify the rendered HTML after adding the code.

Do meta keywords help Google index a page?

No. Google says the keywords meta tag has no impact on indexing or rankings. To diagnose indexing, use Search Console and review robots directives, canonicals, page accessibility, and content quality.

Should I put meta keywords in header.php or functions.php?

A wp_head function in a child theme is usually more flexible and maintainable. Editing header.php can work for a classic theme but may be less suitable for block themes or sites that frequently change templates.

How many meta keywords should I add?

There is no recommended number for Google SEO because Google ignores this tag. If another system requires it, follow that system’s documentation and use a small, accurate set rather than a large list of loosely related terms.

Final thoughts

You now know how to add meta keywords in WordPress without plugin files or third-party SEO interfaces. Use a child theme, output valid escaped HTML through wp_head, and verify the live page source. Most importantly, separate the technical ability to add a tag from the assumption that it will improve rankings. For Google SEO, useful content and a healthy site deserve the attention.

Sources and further reading

Keep Reading

Tutorials · 11 min readHow to Update WordPress Theme Safely (Step-by-Step Guide) Tutorials · 13 min readHow to Migrate WordPress Site to Shopify Without Losing Important Content Tips & Best Practices · 12 min readHow to Optimize WordPress Website Speed: A Complete Guide

Ready to Build Better WordPress Forms?

Start with the free WForms plugin, pick a ready-made template and customize it in Elementor.

More Articles