Jerome's Keywords - Meta Keywords

Updated 13-Jan-2007 15:49
<div class="subtitle"><a href="/wp-keywords" title="Jerome's Keywords Plugin">Back to Jerome's Keywords (main)</a></div>

There are many kinds of meta tags that can be placed in your page header which provide extra information about that page. The keywords tag used to be fairly important to search engines, but has fallen out of use due to years of abuse. However, I still think it’s valid to tag web pages with relevant keywords in order to create a good information architecture. Don’t fool yourself into thinking that this will help your search engine placement!

To add a keywords meta tag, insert the follow on its own line in your page header block (between <head> and </head> tags): <meta name="keywords" content="<?php the_keywords(); ?>" />

This is most likely in your header.php template file, but may need to be added to other files depending on your theme.

The above function will output a comma-separated list of all keywords and category names used on the current page. Additionally, if this is main index page (i.e. “home”) then all categories will be included. You can also customize this function with the following parameters:

  • before — text/html to insert before each keyword. The default is nothing ('’).
  • after — text/html to insert after each keyword. The default is nothing ('’).
  • separator — text/html to insert between each keyword. The default is a comma (’,').

There is also a non-echoing version, getthekeywords() which also accepts a fourth parameter:

  • include_cats — determines what categories to list
    • 'default' causes only the current page’s categories to be listed, unless this is the home page in which case all categories will be listed. This is the default value.
    • 'all' causes all categories to listed.
    • '' (nothing) causes no categories to be listed.

Either of these functions can be used anywhere in your template files (they don’t have to be used for meta tags).