Create a Glossary with WordPress

[EDIT: Tested with WordPress 2.7.1]
I wanted to create a glossary that facilitates terms, buzz words and acronyms used in modern computing. I needed something that was simple to update and manage, and use the capabilities of WordPress rather than creating a simple page with hyperlinks/bookmarks, which would require jumping back and forth into code. I found a few Glossary plugins like IMM-Glossary, which did have management of the glossary posts, however, the definitions were in plain text, and wouldn’t allow formatting. I wanted my text to be formatted using headings, bullet points, even pictures. After many hours of googling and hours of trail and error, I’ve come up with my perfect glossary solution.

This solution allows me to create the glossary content using WordPress posts, and manage the content like any other posts. It uses a mixture of plugins, templates and custom code, and for me it works really well.

Step 1

Download and install the WP-SNAP! plugin. WP-SNAP! creates an alphabetical listing of post titles on a Category or Page template file. Navigation through the listings WP-SNAP! generates is accomplished using the alphabet itself. (For example, if a site visitor clicked on the letter D, any post titles that began with that letter would be showcased.) WP-SNAP! will work on any WordPress 2.1.x or higher site, but is particularly useful managing glossaries, indexes, reviews, or directories.

Step 2

To hold all my glossary terms I need to create a new category in WordPress. I called this category “Glossary”, and made a note of it’s ID (13).

Now that I have my category, I need to change the display of the page when someone clicks on Glossary to make use of the WP-SNAP! plugin, and if anyone clicked on the other categories they would get the ‘normal’ layout. For this I made use of the category template and the template hierarchy.

The first step in modifying what happens when someone visits a Category page is to figure out which of your theme’s files is going to be used to display the posts. This is known as the Template Hierarchy.

In the case of categories, the hierarchy is fairly simple. For instance, the ID number of the Glossary category is 13. The Template Hierarchy specifies that WordPress will use the first Template file it finds in your current Theme’s directory from the following list:

  1. category-13.php
  2. category.php
  3. archive.php
  4. index.php

That is, if you do not have a category-13.php, WordPress will check for a category.php, and so on. So, if you want to make the Category whose ID number is 13 look different from what it is currently (and different from other Category pages), you would want to create a category-13.php file. If you want to make all Category pages look different from other archive pages (such as date and author archives), then you would want to create or modify the category.php file. If you want to make changes to the look of all archive pages, you can create or modify the archive.php file. And if you modify the index.php file, you will affect your entire blog.

So to create a new category-13.php glossary file I copied the next file in the hierarchy that existed in this case archive.php.

I made a few changes to the category-13.php page to remove the post dates, tags etc and added the WP-SNAP! configuration line.

<?php get_header(); ?>
 <!-- Container -->
 <div id="content">
  <!-- Start Postwrap -->
  <div class="postwrap">
   <?php if (have_posts()) : ?>
    <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
    <?php /* If this is a category archive */ if (is_category()) { ?>
     <h2 class="pagetitle"><?php single_cat_title(); ?></h2>
     <?php } ?>
      <?php if (function_exists('wp_snap')) { echo wp_snap(13, FALSE); } ?>
       <?php while (have_posts()) : the_post(); ?>
       <div class="Post" id="post-<?php the_ID(); ?>" style="padding-bottom: 40px;">
        <div class="posthead">
         <h1><a title="Permanent Link to <?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
         <small class="postauthor"><?php edit_post_link('Edit'); ?></small>
        <div class="postcontent">
         <?php the_content() ?>
        <div class="clearer"></div>
      <?php endwhile; ?>
     <?php else : ?>
    <h2>Not Found</h2>
    <?php include (TEMPLATEPATH . '/searchform.php'); ?>
   <?php endif; ?>
  <!-- End Postwrap -->
  <?php get_sidebar(); ?>
  <!-- Container -->
<?php get_footer(); ?>

Step 3

Add some CSS style to your WordPress theme to style the ABC layout, the style I used was was:

ol.snap_nav {
 display: inline;
 float: left;
 clear: both;
 list-style: none;
 font-size: 12px;
 letter-spacing: 3px;

ol.snap_nav li {
 display: block;
 float: left;
 padding: 0 2px 10px 0;

ol.snap_nav li a {
 font-weight: bold;

ol.snap_nav li.snap_selected a {
 font-weight: normal;
 font-size: 20px;
 text-decoration: none;
 color : #003399;

Step 4

Now that the glossary is all setup, a few final tweaks. If I add a new term to the glossary category, I don’t want it appearing in the front page blog nor in the rss feeds. I looked around to find a way of omitting a certain category from the front page, and although there were a few plugins available, I found this an overkill for this one-off implementation. I finally found some code that can be used. All you need to do is add the following code anywhere in the theme functions.php file.

/* Exclude Category from Main Page and RSS Feeds. Used for Glossary(ID=13) Category. */
function myFilter($query) {
	if ($query->is_feed || $query->is_home) {

return $query;


The code example above excludes the glossary category (13) from the RSS feed and main page. If you want to exclude multiple categories, simply add a comma (,) and a dash (-) followed by the category ID e.g. ‘-5,-6,-7′.

Step 5

So far so good. I now wanted the glossary link to appear as a page, i.e. I wanted it to look like a page and have the link at the top where my WordPress pages lived. There were several options available, all using various plugins or required creating pseudo pages and linking it back to a category, all of which looked to messy for me. So instead, I just modified my themes header.php file and created a physical link to the category page. I inserted the following code, just after the code for WordPress page links

 <li><a href="<?php echo get_option('home'); ?>/">Home</a></li>
  <?php wp_list_pages('title_li=&depth=1'); ?>
 <li><a class="" href=""><span>Glossary</span></a></li>

Step 6

Finally, as I had the glossary category as a page link, I wanted to hide the glossary category from the category widget. Once again, plenty of plugins available, but for me again this was an overkill. Having searched various forums I came across the best way to achieve this. This solution requires changes to the WordPress core file widgets.php. I know this is not ideal, and if I upgrade to the next version of WordPress I’d loose my changes, but hey, that’s what this article is for, so I can recreate the glossary fairly easy.

Find this line in /wp-includes/widgets.php

$cat_args = "orderby=name&show_count={$c}&hierarchical={$h}";

In WordPress 2.7.1 its

$cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);

and add the &exclude (WordPress 2.7.1 = ,'exclude') to the end of it followed by the category ID, e.g to exclude category ID 13

$cat_args = "orderby=name&show_count={$c}&hierarchical={$h}&exclude=13";

WordPress 2.7.1 :

$cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h, 'exclude' => '13');

to exclude multiple categories, enter the ID separated by commas (,). e.g exclude category ID’s 5, 6, & 7

$cat_args = "orderby=name&show_count={$c}&hierarchical={$h}&exclude=5,6,7";


You should now be set, I know there are a number of steps involved, but I hope you agree it’s well worth it. I know have a glossary that is managed by WordPress. All I need to do is create a new post and assign it to the glossary category, and I can manage the definitions as I would any other post within WordPress.

WP-SNAP! Configuration

Grapii Glossary


  1. This is cool, but what if I want to still have the preview tooltip on my definition like IMM-Glossary does.. can the 2 be integrated?

  2. thank you rajest, this article is very usefull for me. but actually, i want to search article that explain how to create category list on another (new) file, but in that file, i want to put an alpabethical category ;)

  3. awsome man, i tried alot of site for help to start a dictionary site for my local language, u can make a theme and relase , which will very usefull for people to start a glossary site

  4. Pingback: SEO
  5. Hello!
    Great guide, everything is clear.

    At the alphabetical list, I get this error:

    Warning: Missing argument 2 for SearchEverything::se_log_query() in C:\wamp\www\wordpress\wp-content\plugins\search-everything\search-everything.php on line 848

    How come?
    What could it be?

    Thank you! ;)

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>