How to Add Meta Keywords in WordPress Without a Plugin

You can add a keywords meta tag with a few lines of code in a child theme, and this guide shows how. But Google has ignored the tag since 2009 and Bing reads it mainly as a spam signal, so first decide whether you need it at all, and what to set instead.

In this article
  1. 01The short answer
  2. 02Step 1: Make a child theme
  3. 03Step 2: Add the code
  4. 04Step 3: Set the keywords on a page
  5. 05One set of keywords for the whole site
  6. 06If you change themes often
  7. 07What to set instead of keywords
  8. 08Or let an agent make the change
Key takeaways
  • A custom field and a short wp_head function in a child theme add a keywords meta tag without a plugin.
  • Google has ignored the keywords meta tag in web ranking since 2009.
  • Bing has said it reads the tag as a signal for finding spammers, not for ranking.
  • Put the code in a child theme or a must-use plugin, so a theme update doesn't remove it.
  • Turn on Custom fields in the editor's Preferences to set keywords page by page.
  • Titles, meta descriptions, headings, internal links and structured data matter far more.

The short answer

Add a custom field called meta_keywords to the page, and a short function in a child theme’s functions.php that prints it in the page head. The steps and code are below. Before you start, know what the tag does today:

  • Google doesn’t use it: it announced in September 2009 that its web search disregards the keywords meta tag in ranking.
  • Bing has said it reads the tag as a signal for finding spammers, not for improving rank (Search Engine Land, 2011).
  • WordPress doesn’t add a keywords tag by itself.

For search, the page title and meta description are what count. Keywords are worth adding only if something else reads them, such as an internal search tool, or a client brief that asks for them.

Step 1: Make a child theme

Put the code in a child theme, so a theme update doesn’t wipe it out. A child theme is a folder in wp-content/themes with two files. For Twenty Twenty-Five, style.css needs just this header:

/*
Theme Name: Twenty Twenty-Five Child
Template: twentytwentyfive
*/

Add a functions.php file next to it, then activate the child theme under Appearance > Themes. WordPress’s child theme guide covers the details. Block themes load functions.php just like classic themes do.

Step 2: Add the code

Paste this into the child theme’s functions.php. The first line, <?php, has to be the very first thing in the file. The function prints a keywords tag on any page or post that has a meta_keywords custom field, and nothing anywhere else:

<?php

add_action( 'wp_head', 'mytheme_meta_keywords' );

function mytheme_meta_keywords() {
	if ( ! is_singular() ) {
		return;
	}
	$keywords = get_post_meta( get_queried_object_id(), 'meta_keywords', true );
	if ( $keywords ) {
		echo '<meta name="keywords" content="' . esc_attr( $keywords ) . '">' . "\n";
	}
}

Test on a staging copy first: a typo in functions.php can take the site down until it’s fixed.

Step 3: Set the keywords on a page

  1. Open the page in the editor.
  2. Open the options menu (the three dots, top right), choose Preferences, and turn on Custom fields. The editor reloads.
  3. Scroll to the Custom Fields box below the content, add a field named meta_keywords, and enter your keywords separated by commas.
  4. Update the page, open it, and view the page source: the <meta name="keywords"> line should be in the head.

One set of keywords for the whole site

If you only want one keywords tag on the homepage, skip the custom field and put this function under the first line of functions.php instead:

add_action( 'wp_head', 'mytheme_home_keywords' );

function mytheme_home_keywords() {
	if ( is_front_page() ) {
		echo '<meta name="keywords" content="wordpress agency, care plans, website support">' . "\n";
	}
}

Keep it short and true to the page: a long list of unrelated terms is exactly what Bing treats as a spam signal.

If you change themes often

Code in a theme leaves with the theme. If the site might switch themes, put the same function in a single file in wp-content/mu-plugins instead, starting with the same first line. WordPress loads every PHP file placed directly in that folder, with no activation step, so the tag survives a theme change. Strictly speaking that is a small plugin, but there is nothing to install from the directory or update.

What to set instead of keywords

  • A clear title tag for every page, with the words people actually search.
  • A meta description that makes someone want to click. WordPress doesn’t output one by itself, so a theme, an SEO plugin or a few lines of code has to add it.
  • Headings and copy that answer the question the page targets.
  • Internal links from related pages, with descriptive link text.
  • Structured data for articles, products and FAQs, so search engines understand the page.

New to the basics? See how to use WordPress.

Or let an agent make the change

Head tags are a small change in a risky place. With WPOS, the agent works inside wp-admin on your site: you describe the change, it makes it, and it checks the page before it reports back.

“Add a keywords meta tag to the product pages from a custom field, then check it appears on three of them.”

WPOS is our product, so weigh this section accordingly; you can try it free for 30 days with 5,000 credits, a live site plus a staging sandbox, and no card.

Frequently Asked Questions

No. Google announced in 2009 that its web search disregards the keywords meta tag in ranking.

No. WordPress doesn't output a keywords tag on its own; you add it with code or a plugin.

Google ignores them. Bing has said it uses the tag mainly to detect spam, so a long list of unrelated terms could count against a site there.

In the page head. The function above hooks into wp_head, which every theme prints inside the head.

Yes. Block themes load functions.php like classic themes, so the same code works in a child theme of Twenty Twenty-Five.

The title tag, the meta description, the headings and copy, internal links and structured data.

Describe the change. Skip the code.

WPOS puts an AI agent inside wp-admin that builds natively in Gutenberg, Elementor and Divi and checks its own work. Free for 30 days: 5,000 credits, a live site plus a sandbox, no card.

Start free