Jerome's Keywords - Top Keywords List

Updated 13-Jan-2007 15:53

You can output a list of the most-used keywords on your site by putting <?php top_keywords() ?> anywhere in your template files. This can be in the sidebar, header, main page, or on a separate page like the keyword cosmos.

You can customize the look of your list by using the following optional parameters:

  • number — the number of top keywords to display. The default is false, which lists all of them.
  • element — the text/html output for each keyword. The default value is <li><a href="/tag/%keylink%">%keyword%</a></li> You can use any text you like and the function will automatically replace the following identifiers:
    • %keyword% is replaced by the actual keyword.
    • %keylink% is replaced by a URI-safe version of the keyword for use in links.
    • %count% is replaced by the number of times the keyword is used.
    • %em% and %/em% are replaced by html <em> and </em> tags (respectively), repeated as many times as the keyword is used. This is how Technorati styles their cosmos.

  • elementcat — same as element, but for categories. The default is blank ('’), which excludes categories from the list.
  • mininclude — the minimum count to include a keyword in the most-used list. The default is 0.

Usage is similar to all_keywords() so you can check out the cosmos page for examples.

get_top_keywords() is a non-echoing version of this function.