Tech Notes

Create A Glossary for Your WordPress Site

Two Word­Press plu­g­ins, Nathan Olsen’s WP-SNAP! and Joel Bennett’s Ubernyms work together to cre­ate an inter­ac­tive glos­sary for your site. (Note that I no longer use this tech­nique on my site). more →

Create A Glossary for Your WordPress Site

Notebook Glossary used in an earlier version of this site. I no longer use the method described in this post.

I’ve been look­ing for a way to cre­ate a glos­sary for this site that would:

  • allow alpha­bet­i­cal nav­i­ga­tion, of course. And take full advan­tage of a Word­Press post’s title, excerpt and body for its display.
  • auto­mat­i­cally insert an indi­ca­tor next to the glos­sary term in any post or page that links directly to the glossary.
  • use WordPress’s cat­e­gories to cre­ate hier­ar­chi­cal struc­tures. The idea here is that you can cre­ate hier­ar­chies to show rela­tion­ships like syn­onyms or antonyms. I am only guess­ing that this is possible.

Well, two of three ain’t bad. (I’m still won­der­ing if there is a way to show rela­tion­ships between glos­sary terms.) To see the results in action, con­sider the term, micro­for­mats. The pen­cil icon small caps font indi­cates it is a glos­sary term. Click­ing it the term brings you to the Note­book Glos­sary and a brief descrip­tion. Click­ing on the title brings up the com­plete post.

In ver­sion 0.7 of his WP-SNAP! plu­gin, Nathan has restored the abil­ity to pass a cat­e­gory num­ber directly to the plu­gin, mak­ing it once again com­pat­i­ble with Word­Press Pages. This is great news, but I’ve opted not to intro­duce a glos­sary until all three of my glos­sary cri­te­ria can be met.

Step-by-Step

  1. Install and con­fig­ure WP-SNAP! Nathan’s clever plu­gin (v0.5.1) offers a way to nav­i­gate through a cat­e­gory of posts using alpha­bet­ized pag­i­na­tion. Install and acti­vate the plu­gin as per his direc­tions. In the con­fig­u­ra­tion options, I elected to dis­play both title and excerpt, and accepted the default for the rest.
  2. Cre­ate a Glos­sary Page and a unique glos­sary cat­e­gory. All glos­sary posts will be assigned to this cat­e­gory. Add this line, which will dis­play con­tent for a glos­sary cat­e­gory only, to the Page
  3. Include the con­di­tional func­tion, which checks to see if the plu­gin is enabled, and with­out which the page borks when the plu­gin is dis­abled. Replace catID with your cat­e­gory ID:
    <?php
      if (function_exists('wp_snap')) {
      echo wp_snap('catID');
    ?>
  4. Install and con­fig­ure Ubernyms. Jaykul’s remark­able plu­gin (v2.5) lets you con­fig­ure words that you always want linked. In fact, it does far more than this, in par­tic­u­lar can be used to con­fig­ure a set of fre­quently used abbre­vi­a­tions. But for this project, sim­ply add each new term to the con­fig­u­ra­tion panel, assign­ing each one as Just Link and a Make Link to the glos­sary (e.g. for micro­for­mats it’s …/glossary/?snap=M)
  5. Add CSS styling. Sur­pris­ingly, this step requires most of the effort. WP-SNAP! does not include any styling, so you must pull out the style sheet and go to town. Ubernyms does include styling, to which I added these lines to insert a small book icon next to the link to indi­cate it is a glos­sary item:
    a.uttJustLink {
      background: url('/pencil.png') center right no-repeat; padding-right: 12px;
    }

Lim­i­ta­tions

I am quite happy to have my Note­book Glos­sary up and run­ning almost effort­lessly. Still, noth­ing is perfect:

  • There are just too many auto links. I mean, if you are prone to repet­i­tive term syn­drome like I am, and find occa­sion to micro­for­mats this and micro­for­mats that, you find your­self ask­ing how many time do you really need to auto link micro­for­mats to the glos­sary in a sin­gle post? One micro­for­mats link really ought to do.
  • There are con­flicts with other link styling plu­g­ins such as Denis de Bernardy’s Exter­nal Links plu­gin.
  • By CSS styling the Ubernyms uttJustLink class, I’ve effec­tively elim­i­nated the pos­si­bil­ity of using non-glossary auto links because they too would be styled with the glos­sary book icon. It would be great to be able to add unique styling for glos­sary terms, or use some other tech­nique all together. This is pos­si­ble, but requires mod­i­fy­ing the plu­gin. Jaykul has put this on his to-do list for future plu­gin developments.
  • This is less a prob­lem than a missed oppor­tu­nity: The Ubernyms plu­gin makes use of DomTT tool-tips (a javascript library that lets you add cus­tom tool-tips to web pages) that lets you add, say, def­i­n­i­tions to the tool-tip. This lets you read the def­i­n­i­tion of the term sim­ply by hov­er­ing your mouse over the term. There is no need to visit the Glos­sary. Even so, I hes­i­tate to enter the same excerpt twice, in both the glos­sary and tool-tip. That’s anti­thet­i­cal to nature of a database-driven web site.

Feed­back

If you try this approach for cre­at­ing a glos­sary, or any sug­ges­tions how to bet­ter imple­ment this idea, do share it by leav­ing a com­ment here.

In the cur­rent ver­sion of WP-SNAP! (0.61), plu­gin author Nathan has removed the option to pass a cat­e­gory num­ber directly to the plu­gin. This means it is no longer com­pat­i­ble with Pages. Fur­ther­more, I find that Jaykul’s Ubernyms does not play well with Word­Press 2.1. So, I am tak­ing my glos­sary offline until I find a bet­ter solution.

For those (see com­ments) who can’t decide if chrono­log­i­cal or alpha­bet­i­cal nav­i­ga­tion is bet­ter, you might want to inves­ti­gate Owen Kelly’s glos­sary imple­men­ta­tion, which lets you alter­nate between both views. It’s part of his larger “Memi” project, an attempt to build a per­sonal learn­ing space. See the glos­sary in action in the devel­op­ment cat­e­gory page.

A glos­sary Word­Press plu­gin is now avail­able. The Inter­net Mar­ket­ing Mon­i­tor offers IMM-Glossary, a plu­gin that has much of the same func­tion­al­ity as I’ve writ­ten here. It cer­tainly is much eas­ier to use than set­ting up two plu­g­ins to work together. In addi­tion, it offers an option to link to just one instance of a term in a post or page, rather than all of them. On the other hand, it doesn’t seem to take advan­tage of the Word­Press posts struc­ture and all the advan­tages that implies, or at least doesn’t inte­grate the terms into posts as well as WP-SNAP! does. For me that’s impor­tant, so I am stick­ing with the method I’ve writ­ten here. Yet, all in all, a plu­gin that def­i­nitely deserves your atten­tion if you want a glos­sary for your Word­Press site.

♦ ♦ ♦

14 Comments

  1. sue
    Posted March 18th, 2010 at 9:10 AM | Permalink

    Hi, I found this post online. I wish to add a nice glos­sary to my fash­ion blog. I saw that u men­tion word­press but I. Work with blog­ger. Is there any tip, sug­es­tion or way for me to add a glos­sary to my blog? I appre­ci­ate ur time. Thanks so much

    • Posted March 18th, 2010 at 10:15 AM | Permalink

      Sue — I’m afraid I am not famil­iar at all with blog­ger glos­sary resources. And I still don’t think you can cre­ate a robust glos­sary in Word­Press either. How­ever, if I were to set up a web­site with a glos­sary today, I would look to Dru­pal and its glos­sary mod­ule. It meets all three require­ments I asked for in this arti­cle, plus more.

  2. Posted May 31st, 2007 at 6:25 PM | Permalink

    Shanta,
    WP-SNAP! works with Pages again. :)

  3. Posted November 8th, 2006 at 10:32 PM | Permalink

    A ques­tion always worth ask­ing, Scott. I don’t like the idea of cat­e­go­riz­ing my note­book entries; they are top­ics that I am inter­ested in, but still don’t know very much about. That means it’s a lit­tle early to peg a cat­e­gory, or impose a struc­ture like a site map. But I do want to find them. For me, there’s no bet­ter way to do this than to auto­mat­i­cally link to these entries any time I men­tion them else­where in the site (using Ubernyms). As for alpha­bet­iz­ing? Yes, that’s arbi­trary, but no more arbi­trary than reverse chronology.

  4. Posted November 4th, 2006 at 1:44 PM | Permalink

    It’s a nice idea. Where does it give ben­e­fit, where a sim­ple sitemap and cat­e­gory list does not?

  5. Posted August 21st, 2006 at 8:26 PM | Permalink

    Marc, for­tu­nately, you don’t need to be a PHP expert to make this work. How­ever, you do have to know a lit­tle bit about how Pages oper­ate in Word­Press. The eas­i­est approach is to mod­ify either index.php or page.php as fol­lows, and save the new file as glossary.php. This exam­ple assumes you have pre­de­fined a glos­sary cat­e­gory with a cat­e­gory ID of 5. Hope this helps:

    
    <?php
    /*
    Template Name: Glossary Page
    */
    ?>
    
    <?php get_header(); ?>
    <div id="content">
    
    <?php echo wp_snap('cat_ID'); ?>
    
    </div>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    
  6. Posted August 21st, 2006 at 1:37 PM | Permalink

    Hi,

    Just found this site, and would appre­ci­ate some insight on how to set this up on my pages. I may have missed some­thing, but step 2 in the above instruc­tions doesn’t go into much detail, how exactly does one paste the code into a page? I’m a PHP new­bie, so please be gen­tle. ;-))) Thanks!

  7. Posted July 14th, 2006 at 8:12 PM | Permalink

    Clau­dio — You don’t need to have a cat­e­gory tem­plate to make this work. How­ever, if you don’t use category.php, then you’ll need to assign all posts you want included in the glos­sary to a sin­gle cat­e­gory ID, and then use the func­tion call to dis­play con­tent for this cat­e­gory on a Page. This is in fact the pro­ce­dure I describe here (the Musil theme I am cur­rently using doesn’t have a cat­e­gory tem­plate either).

  8. Posted July 14th, 2006 at 3:00 AM | Permalink

    I don’t have any category.php file in my theme (3k2); what could I do to have a Glos­sary?
    Thanks

  9. Posted July 8th, 2006 at 10:54 PM | Permalink

    Hi Nic — Glad you found it use­ful. If I under­stand you cor­rectly, you\‘ve cre­ated a unique cat­e­gory page for your glos­sary, which sounds like a good idea too. I cre­ated a Page (i.e. with a cap­i­tal P) because I wanted to take advan­tage of the page nav­i­ga­tion tabs in my Word­Press template.

  10. Posted July 8th, 2006 at 7:01 AM | Permalink

    Hello Shanta,
    I just wanted to thank you for this. I found a link to your page on the WP forum, and fol­lowed your instruc­tions and now have a great Glos­sary on my site! This is nec­es­sary for me as it con­tains a fair amount of tech­ni­cal terms.
    I, as you, wish that only the first occurence of a word on a page was linked, but I can live with it.
    One ques­tion though, if I might. I’m curi­ous. You say to cre­ate both a page for the glos­sary and a cat­e­gory. I’m not sure what you mean by that? The way I’ve done it was to cre­ate a cat­e­gory (as it hap­pens with an ID of 22), and then a tem­plate for it call­ing category-22.php. Is this what you meant? If not, what did you mean? No big­gie, it’s work­ing for me, just curi­ous.
    Cheers
    Nic

  11. Posted May 21st, 2006 at 8:46 PM | Permalink

    DG — Your best bet may be to con­tact the authors of the plu­g­ins. I’m not famil­iar enough with them to answer your ques­tions. By the way, I also use SK2 and Akismet; WP-SNAP! didn’t cause any problems.

  12. Posted May 21st, 2006 at 8:39 AM | Permalink

    O.K another issue is with wp-snap. When I acti­vate this plu­gin SK2 and Akismet etc. plu­g­ins gets de-activated.

    I have cre­ated a page tem­plte and with the fol­low­ing “. 165 being carte­gory ID. But I receive an error while view­ing the page Error:
    Warn­ing: Invalid argu­ment sup­plied for fore­ach() in /blog/wp-content/plugins/wp-snap.php on line 196

    Word­Press data­base error: [You have an error in your SQL syn­tax. Check the man­ual that cor­re­sponds to your MySQL server ver­sion for the right syn­tax to use near \’) AND ‘post_id‘ = ‘ID‘ AND ‘post_status‘ = \‘pub­lish\’ AND ‘categ]
    SELECT ‘post_title‘, ‘post_content‘, ‘post_excerpt‘, ‘ID‘, ‘post_password‘ FROM wp_posts, wp_post2cat WHERE ) AND ‘post_id‘ = ‘ID‘ AND ‘post_status‘ = \‘pub­lish\’ AND ‘category_id‘ = \‘165\’ ORDER BY ‘post_title‘ ASC

    Can you look at it and advice.

    DG…

  13. Posted May 21st, 2006 at 8:22 AM | Permalink

    Hi Shanta,

    I need your help for following:

    Ubern­mys — I had installed this plu­gin many time, but it does not pop-up abbr or acronymn defs. I had writ­ten to Joel also, but could not hear any­thing from him.
    Could you advice me of ‘what could be the pos­si­bil­ity of the plu­gin not work­ing here?‘
    DG…

3 Trackbacks

  1. By IMM-Glossary WordPress Plugin on September 14th, 2007 at 10:12 AM

    […] to announce the imme­di­ate release of our first Word­Press plu­gin:  IMM-Glossary. […] Cre­ate A Glos­sary for Your Word­Press Site | Shanta Rohse on Decem­ber 13th, 2006 at 7:57 pm […]

  2. By nateomedia | WP-SNAP! WordPress Plugin on February 19th, 2007 at 12:43 AM

    […] […] Make that two steps for­ward, two steps back. In the cur­rent ver­sion of WP-SNAP! (0.61), plu­gin author Nathan has removed the option to pass a cat­e­gory num­ber directly to the […] Cre­ate A Glos­sary for Your Word­Press Site | Shanta Rohse […]

  3. By The Wheeling Gourmet « WordPress Support on July 9th, 2006 at 1:36 AM

    […] Yeah, the glos­sary thing is kinda neat. I wish I could claim it as my own, but it’s not ;) Shanta describes the tech­nique here: shantarohse.com/wordpress/create-a-glossary-for-your-wordpress-site […]

Post a Comment

Your email is never published nor shared. 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>

Subscribe without commenting