How to Add Meta Keywords in WordPress without Plugin
Add the old meta keywords tag using safe code snippets and custom fields—no SEO plugin required.
The meta keywords tag is one of those persistent SEO myths in WordPress. Most modern search engines ignore it, yet you may still need it for legacy systems, internal search tools, or specific regional search engines. The good news: you can add meta keywords in WordPress without installing yet another plugin.
In this tutorial, you’ll learn how to add a clean, per-post <meta name="keywords"> tag using a small code snippet and WordPress custom fields. By the end, you’ll be able to manage meta keywords directly in the editor while keeping your theme fast and uncluttered.
If you’re new to optimization in general, it can help to first understand what SEO on WordPress really means, then come back here for this optional, more advanced tweak.
Prerequisites
Before you start editing code, make sure you have the basics in place. You don’t need to be a developer, but you do need to be comfortable copying and pasting small snippets.
- Administrator access to your WordPress dashboard.
- Access to your theme files via FTP/SFTP or your hosting file manager.
- A child theme active (recommended) so theme updates don’t overwrite your changes.
- Classic Editor or familiarity with enabling Custom Fields in the Block Editor.
functions.php. Step 1: Decide Whether You Really Need Meta Keywords Wordpress
Before you write any code, decide why you want meta keywords at all. Google, Bing, and many major search engines no longer use this tag for rankings. However, some legacy tools, older search engines, and custom site search implementations may still rely on it.
Use meta keywords only when you have a clear reason—such as integrating with a third-party system or maintaining compatibility with an older SEO setup. More importantly, make sure you’re using keywords correctly on the page itself. Our guide on adding keywords in WordPress without hurting your SEO walks through how to choose phrases that help rather than harm.
As a rule of thumb, keep each post’s meta keywords list short and focused—usually 3–8 phrases, separated by commas, that truly reflect the content of that page.
Step 2: Enable Custom Fields in the Editor
To avoid hard-coding keywords, you’ll store them in a custom field on each post or page. First, make sure the Custom Fields panel is visible in your editor.
2.1 Enable Custom Fields in the Classic Editor
- Log in to your WordPress dashboard and edit any post.
- At the top right, click Screen Options.
- In the dropdown panel, check the box labeled Custom Fields.
- Close the Screen Options panel; the Custom Fields box should now appear below the content editor.
2.2 Enable Custom Fields in the Block Editor (Gutenberg)
- Edit a post or page in the Block Editor.
- Click the three-dot Options menu at the top right.
- Choose Preferences → Panels.
- Enable the Custom fields option, then reload the editor when prompted.
- Scroll down below the content area to find the Custom Fields panel.
Step 3: Add a Meta Keywords Field to Your Post
Now you’ll create a reusable custom field that will hold your comma-separated meta keywords for each post. You’ll only need to create the field name once; afterward, you’ll just fill in the value.
- With the post open, scroll down to the Custom Fields box.
- If you don’t have any fields yet, click Enter new.
- In the Name box, enter
meta_keywords(all lowercase, underscore instead of space). - In the Value box, enter a few relevant keywords separated by commas, for example:
wordpress meta keywords, seo settings, custom meta tags - Click Add Custom Field, then update or publish your post.
meta_keywords field name on every post so your code only has to look for a single key. Step 4: Add a Meta Keywords Snippet to functions.php
Next, you’ll hook into WordPress’s wp_head action so your site automatically prints the meta keywords tag in the <head> area whenever a post has the meta_keywords field filled in.
4.1 Open Your Child Theme’s functions.php
- Connect to your site via FTP/SFTP or open your hosting file manager.
- Navigate to
wp-content/themes/your-child-theme/. - Download or open the
functions.phpfile in a text editor.
functions.php in Jannah or any other theme. Updates will overwrite your changes. Always use a child theme or a custom functionality file. 4.2 Paste the Meta Keywords Function
Inside functions.php, add the following code near the bottom of the file, but still inside the opening <?php tag:
// Add meta keywords from a custom field to the <head>
function wph_meta_keywords_tag() {
if ( ! is_singular() ) {
return;
}
global $post;
$keywords = get_post_meta( $post->ID, 'meta_keywords', true );
if ( empty( $keywords ) ) {
return;
}
echo '<meta name="keywords" content="' . esc_attr( $keywords ) . '" />' . "\n";
}
add_action( 'wp_head', 'wph_meta_keywords_tag' );
Save the file and, if you edited it locally, upload it back to your child theme directory. Then refresh your site to make sure there are no PHP errors.
functions.php from your backup and check for missing semicolons, curly braces, or stray characters. If you’re also interested in controlling other meta tags like description or robots, you can combine this approach with our guide on adding meta tags in WordPress for a more complete setup.
Step 5: Test That the Meta Keywords Tag Is Working
With the code in place, it’s time to confirm your meta keywords are actually being output in the HTML head of your pages.
- Open a post where you added the
meta_keywordscustom field in your browser. - Right-click anywhere on the page and choose View Page Source (or press Ctrl + U / Cmd + Option + U).
- Use the find function (Ctrl + F / Cmd + F) and search for
meta name="keywords". - You should see a line similar to:
<meta name="keywords" content="wordpress meta keywords, seo settings, custom meta tags" />
If the tag isn’t there, double-check that you saved functions.php, that the child theme is active, and that the post actually has a meta_keywords custom field set.
Step 6: Maintain and Clean Up Meta Keywords WordPress Over Time
Once everything works, treat meta keywords as a secondary, “nice-to-have” layer rather than your primary SEO tool. Update them when you significantly change the focus of a post, but don’t obsess over minor tweaks.
- Avoid keyword stuffing: Very long lists of keywords can be a red flag in audits and offer little benefit.
- Keep them aligned: Your meta keywords should match the real topic and phrases used in your title, headings, and body content.
- Review periodically: When you update content, quickly review the
meta_keywordsfield and remove outdated phrases. - Be ready to remove: If your SEO strategy changes, you can safely remove the function later; it won’t affect your visible content.
Wrap Up: Meta Keywords WordPress Without a Plugin
You’ve just configured Meta Keywords WordPress to output the meta keywords tag using a lightweight, plugin-free approach. By combining a custom field with a simple functions.php snippet, you stay in control of your code and avoid bloating your site with extra SEO plugins.
Remember that meta keywords are no longer a major ranking factor, so treat them as a bonus layer rather than a core strategy. Keep your keyword lists concise, aligned with your content, and maintained over time, and your WordPress site will stay both clean and flexible for future SEO changes.
Further Reading
- How to Add Meta Description in WordPress
- WordPress SEO: Complete Beginner’s Guide
- How to Do On-Page SEO in WordPress
- How to Add Keywords to a WordPress Website
Frequently Asked Questions
Do meta keywords still matter for SEO today?
Will adding meta keywords slow down my WordPress site?
My meta keywords tag is not showing in the source code. What went wrong?
wph_meta_keywords_tag function is in the child theme’s functions.php, and (3) the post you’re checking has a meta_keywords custom field with a value.If all of that looks correct and the tag still doesn’t appear, temporarily switch to a default theme (like Twenty Twenty-Four) on a staging site and test again. If it works there, your main theme or another plugin may be filtering or overriding the wp_head output. Is it safe to edit functions.php directly on a live site?
functions.php can trigger a “critical error” and lock you out of the admin area until it’s fixed via FTP. That’s why it’s safer to use a child theme and edit files via SFTP or your hosting file manager.Always keep a backup of the original functions.php file before making changes, and test major edits on a staging site when possible. Can I remove the meta keywords code later without breaking anything?
wph_meta_keywords_tag function and its add_action line from functions.php. Your posts will continue to work normally, and only the meta keywords tag will disappear from the page source.The custom field values will remain stored in the database, so you can always re-enable the function or repurpose those values in the future if necessary.




