Adding keywords to your WordPress website

written by Web designers London on November 14, 2012 in SEO and Tutorials and WordPress with no comments


Over the time we have heard how the keyword meta tag has lost a lot of importance for SEO purposes in Google. Whatever the situation we still need them and for those of you who build their websites in HTML adding keywords is a very simple process. You just add the code below containing the relevant keywords to your website:

<meta name="Keywords" content="keyword1,keyword2,keyword3,etc" />

So how do you add keyword meta tags to you website if you are using WordPress? Well you could always use a WordPress plugin and there are plenty about. We thought we would show you how to add keywords using a few lines of PHP and custom fields, so let’s begin.

Firstly you need to open your header.php file in your chosen text editor and add the following code before the closing (HEAD) tag. Change the numbered “keywords” to the main keywords relevant to your website.

<meta name="keywords" content="<?php
while (have_posts()) : the_post();
$keywords = get_post_meta($post->ID, 'keywords', false);
if ($keywords){
echo 'keyword1, keyword2, '.$keywords[0].', keyword3, keyword4';
echo 'keyword1, keyword2, keyword3, keyword4';
?>" />

Once you have that done we need to make sure each page has its own unique relevant keywords as duplicate keywords meta tags are a big no-no for Google. You now need to go in to your WordPress admin panel and edit the page you wish to add keywords too. In this case I will show you how to set up your custom fields in WordPress.

Firstly you need to make sure you have you custom fields tab on if you cannot see it go to the top right of the WordPress backend click on screen options then check custom fields as shown in the image below.


If you scroll down you will see your custom fields input box, you then click on “add new” then in the “name” field you type in “keywords”. Then in the “value” input field you enter you desierd keywords, make sure you keep your keys different from your master chosen keywords as entered in you php code.

keywords custom fields

That’s pretty much it just make sure each page has different and relevant keywords and you are good to go.