Meta Keywords are a specific type of meta tag that appear in the HTML code of a Web page and help tell search engines what the topic of the page is. They look like this:

<meta name="keywords" content="meta keywords html, meta tag generator, meta tags example, meta tag attributes, meta tag in html">

The important thing to keep in mind when selecting or optimizing your meta keywords is to be sure that each keyword accurately reflects the content of your pages.
For some reason, WordPress doesn’t have built-in support for adding SEO keywords, which is why so many third-party plugins have been developed for this purpose. However, you don’t need to install another WordPress plugin to enable the keywords meta tag, as you’ll soon find out in this instructional guide below.

How to Add Keywords In WordPress Without Plugins

To add keywords in WordPress, please follow the steps below carefully.

Step 1.Add The Following Code to the functions.php File

Inside the WordPress dashboard Theme Editor or on the web server, find and open the functions.php file. Go to Appearance -> Theme Editor.

You must create a child theme before making any changes to functions.php file. Otherwise, the applied changes will be lost after each update.
Create child theme in WordPress step by step [without plugin]

As an alternative method, you can use the Code Snippets plugin to insert your codes into WordPress.

Copy the PHP code from the below box and paste it at the end of the functions.php file.

add_action('wp_head', function (){
if( is_single() || is_page() ) {
$meta_keywords_raw = (get_post_meta(get_the_ID(), 'keywords', true));
if ($meta_keywords_raw)	 {
$meta_keywords = preg_replace('/\s*,\s*/', ', ', $meta_keywords_raw);
<meta name="keywords" content="<?= $meta_keywords; ?>">
<?php }} } );

This Is How the Above PHP Code Works

This code puts the keywords that you write in the custom fields in the meta keyword. There are other ways to add keywords, but in this method you will have the most control over the output.

Step 2.Open an existing Post and turn On the Custom Fields Option

Go to WordPress dashboard, then open an existing post to which you want to add meta keywords tag.

At the top right of your WordPress dashboard, you should see three dots. Click on those dots to open the WordPress options menu.
In the pop-up screen for Preferences, click on the “Panel” tab located on the left-hand side.
Under the “Additional” section, click on the “Custom Fields” toggle bar to toggle it to the on position. A page reload is required for this change. Make sure your content is saved before reloading. Then, click on the “Enable and Reload” button that appears.
After the page reloads, a “Custom Fields” section will appear below your WordPress text editor.

activate Custom fields in wordpress

Step 3.Create A Custom Field for Meta Keywords

Scroll down past the bottom of the WordPress text editor to the new “Custom Fields” section that was enabled in the previous step.
You should now see an “Add New Custom Field” area.

Here’s how you create the custom field for meta keywords:

  • Under the “Name” column, click on “Enter New” which is located below the “- Select -” dropdown menu.
  • In the text field that now appears under the “Name” column, type in “keywords”. This will assign a custom field for the meta keywords.
  • In the text field under the “Value” column, type in the keywords you want to be displayed in the meta keywords HTML tag with commas separating each phrase.
  • Click on the “Add Custom Field” button to save this new custom field for the meta keywords.
Add keywords in WordPress Custom Field

Step 4.Update the post and check the result

Go to the post and open the source code by pressing Ctrl+U keys and check the correctness of the keywords meta tag.

meta keywords tag in WordPress

If this article is difficult for you to read in text, you can watch the video version below.

I hope you enjoyed this guide on how to add keywords in WordPress without plugins.
That’s it, If you have a question, be sure to comment for us to answer.

Share this post

Hi, my name is Maya and I’m a WordPress plugin developer. I created this website to share some of the helpful codes that I’ve used in my own projects.
If you’re looking for a custom plugin for your website, you can contact me by clicking on Hire a developer in the menu. I’d love to hear from you.

Articles: 50

Leave a Reply

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