Quick answer: how to add meta keywords in wordpress (fast overview)
If you want the short, actionable version: add a static <meta name="keywords" ...>
to your theme head (use a child theme), use a lightweight header-injection plugin like WPCode/Insert Headers & Footers, or add a dynamic PHP function that pulls post tags or a custom field and echoes a cleaned keywords meta tag in wp_head
. Always back up and test. This article explains each method in depth and gives copy/paste code and test steps.
Why this topic still matters (context you should know)
Meta keywords are an HTML meta tag that historically told search engines which phrases a page targeted. Search engines abused and devalued the tag, so Google now ignores it for ranking. Still, some external systems, enterprise crawlers, local search engines, or internal tools read the tag. If a partner, aggregator, or custom crawler expects a meta name="keywords"
entry, you must provide it. For context, see the official SEO fundamentals from Google's SEO Starter Guide which explains modern priorities like titles, meta descriptions, and structured data.
Practical note: adding a keywords tag will not help Google rank your pages. But it can be necessary for compatibility. That’s the plain truth.
Preparation: safety, backups, and decisions
Never edit live PHP files without a backup. Use a staging environment or at minimum create a full site backup before you touch theme files. Many hosts provide one-click staging; if yours doesn’t, use plugins like UpdraftPlus or your host's backup tool.
- Create a child theme if you will edit theme files. That prevents losing changes on updates.
- Decide whether you want sitewide (same list on every page) or per-post meta keywords.
- Decide your source: static text, WordPress tags, categories, or a custom field.
Real-world example: a portfolio site migrating from static HTML might need the exact old meta keywords replicated to satisfy an external archive service. In that case sitewide, manual insertion via a header plugin is fine and fast.
Method 1 — Static manual insertion: edit header.php (child theme)
When to use it: you want a single sitewide set of keywords. You’re comfortable editing theme files and you use a child theme.
Step-by-step
- Create and activate a child theme if one doesn’t exist.
- Copy
header.php
from the parent theme into the child theme if needed. - Open
header.php
and locate the<head>
section. Insert the meta tag near other meta tags. - Save and upload. Clear caches and verify with view-source.
Code (copy/paste)
<!-- Add this inside your <head> in the child theme header.php --> <meta name="keywords" content="wordpress tutorial, meta keywords, how to add meta keywords in wordpress, seo practices" />
Deep tip: keep the list short and focused (5–15 items). Historically shorter lists worked better for tools that consumed this tag. Avoid duplicate lists across hundreds of pages — that defeats page-level specificity.
Method 2 — Use a lightweight header plugin (non-developer friendly)
When to use it: you don’t want to edit theme files or need editors to manage the tag. Plugins are safe, reversible, and often faster than editing PHP.
Recommended plugins
- WPCode (formerly Insert Headers and Footers)
- Insert Headers and Footers (by WPBeginner)
- Meta Tag Manager or Header & Footer Scripts
Pro tip from community experience: if you just need a simple meta tag, a tiny plugin like Meta Tag Manager does the job without the bloat of a full SEO suite (see the WordPress.org community thread about adding meta tags: WordPress.org support thread).
Step-by-step (WPCode example)
- Plugins > Add New > search for "WPCode" > Install & Activate.
- Open Code Snippets > Header & Footer (or the WPCode header area).
- Paste your meta tag into the Header box, save, and enable.
- Clear caching and verify on the front end.
Example tag to paste
<meta name="keywords" content="wordpress, meta keywords, add keywords, how to add meta keywords in wordpress" />
Why plugin is often best: block themes (like Twenty Twenty-Four) don’t use classic header.php
, so the header plugin is theme-agnostic and persists across theme switches. As noted by theme and plugin writers, WordPress sometimes doesn't include traditional header files in block themes — making header plugins the pragmatic choice (WPZoom's guide).
Method 3 — Dynamic meta keywords generated via functions.php or Code Snippets (recommended for per-post)
When to use: you want unique keywords per page. Use tags, categories, or a custom field and output a sanitized, length-capped keywords string in wp_head
. This is the most maintainable approach for content sites.
Copy/paste PHP (detailed, safe, with comments)
<?php // Add dynamic meta keywords to the <head> for single posts/pages function rg_add_dynamic_meta_keywords() { if ( ! is_singular() ) { return; // only on single post/page } global $post; // 1) Custom field override (meta key: meta_keywords) $custom = get_post_meta( $post->ID, 'meta_keywords', true ); if ( ! empty( $custom ) ) { $keywords = $custom; } else { // 2) Fallback to post tags $tags = wp_get_post_tags( $post->ID, array( 'fields' => 'names' ) ); if ( ! empty( $tags ) ) { $tags = array_slice( $tags, 0, 12 ); // limit count $keywords = implode( ', ', $tags ); } else { // 3) Optional fallback to categories $cats = get_the_category( $post->ID ); if ( ! empty( $cats ) && is_array( $cats ) ) { $cat_names = array_map( function( $c ) { return $c->name; }, $cats ); $keywords = implode( ', ', array_slice( $cat_names, 0, 5 ) ); } else { $keywords = ''; } } } // sanitize and limit length $keywords = trim( wp_strip_all_tags( $keywords ) ); if ( strlen( $keywords ) > 250 ) { $keywords = substr( $keywords, 0, 250 ); } if ( ! empty( $keywords ) ) { echo "\n<meta name=\"keywords\" content=\"" . esc_attr( $keywords ) . "\" />\n"; } } add_action( 'wp_head', 'rg_add_dynamic_meta_keywords' ); ?>
How this works (line-by-line brief):
- Only runs on singular pages to avoid archive noise.
- Checks a custom field named
meta_keywords
first — editors can override automated values. - Falls back to post tags, then to categories if tags are missing.
- Sanitizes output and enforces a 250-character cap to avoid very long meta tags.
- Outputs a safe, escaped meta tag in the head.
Implementation tips: add a small meta box for editors to set meta_keywords
for posts, or use existing custom fields UI. If you prefer not to edit theme files, add the snippet using the Code Snippets plugin so it survives theme updates.
Embed video walkthrough (live coding example)
The following video demonstrates how to add meta keywords manually using PHP and automating tags-to-meta logic. Pause and copy the code when the presenter types it in.
Method 4 — SEO plugin reality check: what plugins do today
Many modern SEO plugins (Yoast, Rank Math, All in One SEO) focus on title tags, meta descriptions, sitemaps, schema, and onpage analysis. Historically some exposed meta keywords fields, but most removed them because Google ignores the tag and the feature was frequently misused. If your goal is general SEO, prioritize title, meta description, structured data, content, internal linking, and performance. For plugin capabilities and templates, check popular plugin docs and community discussion — SEO plugins sometimes add dynamic tag snippets and templates for titles and descriptions, not keywords (WPZoom).
If you still need keywords because of a partner system, verify the plugin supports the tag. Otherwise, use a header plugin or the PHP approach described earlier.
Testing and verification (how to be 100% sure)
After adding a meta keywords tag, verify it with these steps:
1) View page source
Open the page in your browser. Right-click > View Page Source (or press Ctrl+U). Search for meta name="keywords"
. Confirm it appears inside <head>
.
2) Use curl (fast command-line check)
curl -s https://example.com/your-post-url | grep "meta name=\"keywords\""
If it prints a line, the tag exists. Replace the URL with your page.
3) Check cache and plugin conflicts
- If the tag doesn’t show, clear server, CDN (Cloudflare), and plugin caches.
- Temporarily disable other header-injection plugins that might override your tag.
- Ensure you're editing the active theme: block themes may not have header.php accessible — use Code Snippets or a header plugin instead (see the WordPress.org support thread for notes about block themes: WordPress.org support).
Best practices if you decide to use meta keywords
If you must add meta keywords, follow these rules to keep them useful and tame:
- Keep the list focused: 5–15 keywords or phrases. Think of them as internal tags, not a ranking hack.
- Prefer long-tail phrases that describe page intent (e.g., "how to add meta keywords in wordpress") rather than single generic words like "wordpress".
- Limit total characters (200–250 chars is a safe cap).
- Make them unique per page where feasible. Sitewide identical lists reduce usefulness.
- Sanitize user input. If editors can enter keywords, trim tags and strip HTML before output.
- Avoid stuffing: random unrelated keywords will look spammy to any system that parses the tag.
Alternatives you should prioritize instead of meta keywords
Google and modern search engines reward real signals. If your goal is organic visibility, invest time in the following instead of meta keywords:
- Title tags and unique meta descriptions: optimize CTR and include target keywords naturally. Google often uses these in the search snippet. See Google's SEO Starter Guide for specifics on title and snippet best practices.
- Structured data (JSON-LD): use schema to enable rich results (recipes, articles, products, events).
- High-quality on-page content: match search intent and cover topics comprehensively.
- Internal linking and topical clusters: build authority on core subjects and use anchor text sensibly.
- Performance, mobile UX, and accessibility: these are measurable ranking and user-experience factors.
Long example: a local electrician replaced meta keywords with a cluster of service pages (each with schema, unique title/meta description, and internal links). Within months traffic for money-intent queries rose sharply. The takeaway: focus on signals that matter.
Step-by-step checklist and implementation plan
Use this checklist when you’re ready to implement meta keywords on a WordPress site. Think of it as a mini project plan.
- Decide scope: sitewide vs per-page.
- Choose method: header.php (child theme) / header plugin / PHP dynamic snippet.
- Backup site and set up staging if possible.
- Implement code or plugin. Use the provided PHP snippet for per-post automation.
- Clear cache layers (plugin, server, CDN) and test with view-source and curl.
- Create an editor guide: how to fill custom field or manage tags to influence meta keywords.
- Monitor third-party systems that consume the tag to ensure compatibility.
- Reassess after 30–90 days. Remove if unused or irrelevant.
Common pitfalls and troubleshooting
1) Nothing shows up in the head
Causes and fixes:
- Caching: clear plugin cache and CDN caches.
- Wrong theme file: ensure you edited the active theme or child theme. Block themes won't expose header.php.
- Plugin conflict: disable other header-injection plugins temporarily.
2) Duplicated tags or conflicting values
If two plugins or a plugin and theme output keywords, you'll see duplicates. Search for meta name="keywords"
and remove or disable one output method.
3) Editors entering poor keywords
Solution: add a validation step in the meta box, or sanitize input in PHP (strip tags, limit characters, and optionally provide a tagging UI that enforces constraints).
Actionable FAQ (short answers you can act on now)
Q: Will adding meta keywords hurt my SEO?
A: No — modern engines ignore them for ranking. The main downside is maintenance overhead and the potential to feed downstream systems irrelevant data. Keep them reasonable if you add them.
Q: I need meta keywords for a legacy aggregator — what's the fastest safe route?
A: Use a header-injection plugin like WPCode or Meta Tag Manager. It's reversible and works with block themes. See WP community examples where users preferred small plugins for simple meta needs: WordPress.org support.
Q: Can I automate keywords from categories instead of tags?
A: Yes. Replace the wp_get_post_tags
call with get_the_category
and map category names to a comma-separated string. Watch duplicates and length, and sanitize carefully.
Q: What should editors actually type into a meta_keywords custom field?
A: Use precise, long-tail phrases separated by commas. Example: how to add meta keywords in wordpress, wordpress meta tag tutorial, add meta keywords code. Keep the total length under ~250 characters.
Real-world maintenance plan (30/60/90 day)
After adding meta keywords for compatibility, follow this maintenance cadence:
- 30 days: verify that downstream systems are reading the tag as expected. Fix formatting if needed.
- 60 days: review a sample of pages for duplicate or irrelevant keywords and clean them.
- 90 days: decide whether to continue adding keywords. If no system consumes them, retire the feature to reduce maintenance.
Record a short SOP for editors: where to add custom keywords, style rules, and the maximum length. This reduces future errors.
Advanced options and customization ideas
Want more control? Try these advanced tactics:
- Map categories to keyword sets: maintain a small associative array of category->keywords for consistent per-section tags.
- Use taxonomy term meta to store SEO keywords for categories, then pull them automatically for category archives.
- Combine a site-level default with per-post overrides via the custom field. That balances safety and specificity.
- Expose a preview inside the post editor that shows what the meta tag will output (JavaScript + REST endpoint that returns generated keywords).
Fictional story to illustrate: A small e-commerce brand used to rely on a directory that only read meta keywords
. After migrating to WordPress, they used the dynamic PHP method to pull WooCommerce product tags into the tag. The directory resumed indexing their products without manual exports — saving hours per week.
SEO and content strategy (skyscraper technique applied)
The skyscraper technique says: find competitor pages that rank, improve on them materially, then publish the superior version. For the keyword theme "how to add meta keywords in wordpress" you should:
- Audit top-ranking articles and note gaps.
- Create a step-by-step guide (this article), add code snippets, video embed, and troubleshooting checklist.
- Promote the guide to WordPress communities and forums that maintain legacy systems.
- Add internal linking from related articles and cluster pages to concentrate topical authority (see internal link below).
Internal link: if you’re also comparing website builders and deciding between platforms, our detailed comparison can help you choose the right CMS or builder before implementing code: Squarespace vs WordPress vs Wix comparison.
Useful resources and references
- WordPress community thread on meta tag approaches: WordPress.org support topic.
- Detailed how-to on adding meta tags (plugins vs manual): WPZoom: Add meta tags to WordPress.
- Google's official guidance on what matters for search: Google Search Essentials.
Further reading (backlink resources)
For broader SEO tasks that will actually move organic traffic, read the link reclamation guide and the performance content cheatsheet. These resources are excellent follow-ups to technical tweaks:
- The Ultimate How-To Guide to Link Reclamation — learn to reclaim lost backlinks and boost domain authority.
- The Ultimate Guide to Performance Content — a cheatsheet for content that drives traffic and conversions.
Conclusion: apply the right method for your needs
How to add meta keywords in WordPress depends on your use case. For compatibility with legacy systems, use a header plugin or the dynamic PHP snippet. For single-sitewide lists, a child theme edit works. For most modern SEO goals, focus on titles, meta descriptions, schema, and content. If a partner or tool needs meta keywords, implement them safely, test thoroughly, and document the process for editors.
Final actionable step: pick one method above and implement it on a staging site right now. Use the dynamic snippet if you want per-page control. If you want a ready-made small plugin approach, install WPCode and paste a tag into the header. Then verify with the curl command provided earlier.
Appendix: quick code snippets & editor checklist
Quick PHP snippet (short version)
<?php add_action('wp_head', function() { if (is_singular()) { $tags = wp_get_post_tags(get_the_ID(), array('fields' => 'names')); if ($tags) echo "<meta name=\"keywords\" content=\"" . esc_attr(implode(', ', array_slice($tags,0,10))) . "\" />"; } }); ?>
Editor checklist (copy into your CMS SOP)
- If entering manual keywords, use commas to separate phrases.
- Prioritize long-tail phrases (avoid single-word stuffing).
- Keep the total length under 250 characters.
- Use the custom field
meta_keywords
to override defaults. - Notify the webmaster if you need sitewide changes.
Quick troubleshooting FAQ (short)
Q: I added the tag but don’t see it — what now?
A: Clear caches, check you're editing the active theme or using a header plugin, and verify with view-source or curl.
Q: Will adding meta keywords hurt my SEO?
A: No — Google ignores them for ranking. Keep them concise and relevant to avoid confusion in downstream tools.
Q: Need a custom plugin or snippet?
A: I can generate a simple plugin file, a Code Snippets paste, or a tailored functions.php snippet. Tell me your desired source (tags, categories, or a custom field) and limits (max keywords, char length), and I’ll output the exact code.