The WordPress Files
My minor contributions to the WordPress publishing platform.
- Create A Glossary for Your WordPress Site
- Style Author Comments with WordPress Sandbox Theme
In version 0.7 of his WP-SNAP! plugin, Nathan has restored the ability to pass a category number directly to the plugin, making it once again compatible with WordPress Pages. This is great news, but I’ve opted not to include a glossary until I can meet all three glossary criteria.
In the current version of WP-SNAP! (0.61), plugin author Nathan has removed the option to pass a category number directly to the plugin. This means it is no longer compatible with Pages. Furthermore, I find that Jaykul’s Ubernyms does not play well with WordPress 2.1. So, I am taking my glossary offline until I find a better solution.
I’ve been looking for a way to create a glossary for this site that would:
- allow alphabetical navigation, of course. And take full advantage of a WordPress post’s title, excerpt and body for its display.
- automatically insert an indicator next to the glossary term in any post or page that links directly to the glossary.
- use WordPress’s categories to create hierarchical structures. The idea here is that you can create hierarchies to show relationships like synonyms or antonyms. I am only guessing that this is possible.
Well, two of three ain’t bad. (I’m still wondering if there is a way to show relationships between glossary terms.) To see the results in action, consider the term, microformats. The small pencil icon indicates it is a glossary term. Clicking it the term brings you to the Notebook glossary and a brief description. Clicking on the title brings up the complete post.
Step-by-Step
Disclaimer! I am not a programmer, just a keen user. Please keep that in mind as you read how I created the glossary:
- Install and configure WP-SNAP! Nathan’s clever plugin (v0.5.1) offers a way to navigate through a category of posts using alphabetized pagination. Install and activate the plugin as per his directions. In the configuration options, I elected to display both title and excerpt, and accepted the default for the rest.
- Create a Glossary Page and a unique glossary category. All glossary posts will be assigned this category. Add this line, which will display content for a glossary category only, to the Page
- Include the conditional function, which checks to see if the plugin is enabled, and without which, the page borks when the plugin is disabled:
<?php if (function_exists('wp_snap')) { echo wp_snap('catID'); ?> - Install and configure Ubernyms. Jaykul’s remarkable plugin (v2.5) lets you configure words that you always want linked. In fact, it does far more than this, in particular can be used to configure a set of frequently used abbreviations. But for this project, simply add each new term to the configuration panel, assigning each one as Just Link and a Make Link to the glossary (e.g. for microformats it’s …/glossary/?snap=M)
- Add CSS styling. Surprisingly, 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 indicate it is a glossary item:
a.uttJustLink { background: url('/pencil.png') center right no-repeat; padding-right: 12px; }
Limitations
I am quite happy to have my Notebook glossary up and running almost effortlessly. Still, nothing is perfect:
- There are just too many auto links. I mean, if you are prone to repetitive term syndrome like I am, and find occasion to microformats this and microformats that, you find yourself asking how many time do you really need to auto link microformats to the glossary in a single post? One microformats link really ought to do.
- There are conflicts with other link styling plugins such as Denis de Bernardy’s External Links plugin.
- By CSS styling the Ubernyms uttJustLink class, I’ve effectively eliminated the possibility of using non-glossary auto links because they too would be styled with the glossary book icon. It would be great to be able to add unique styling for glossary terms, or use some other technique all together. This is possible, but requires modifying the plugin. Jaykul has put this on his to-do list for future plugin developments.
- This is less a problem than a missed opportunity: The Ubernyms plugin makes use of DomTT tool-tips (a javascript library that lets you add custom tool-tips to web pages) that lets you add, say, definitions to the tool-tip. This lets you read the definition of the term simply by hovering your mouse over the term. There is no need to visit the Glossary. Even so, I hesitate to enter the same excerpt twice, in both the glossary and tool-tip. That’s antithetical to nature of a database-driven web site.
Feedback
If you try this approach for creating a glossary, or any suggestions how to better implement this idea, do share it by leaving a comment here.
For those (see comments) who can’t decide if chronological or alphabetical navigation is better, you might want to investigate Owen Kelly’s glossary implementation, which lets you alternate between both views. It’s part of his larger “Memi” project, an attempt to build a personal learning space. See the glossary in action in the development category page.
A glossary WordPress plugin is now available. The Internet Marketing Monitor offers IMM-Glossary, a plugin that has much of the same functionality as I’ve written here. It certainly is much easier to use than setting up two plugins to work together. In addition, 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 advantage of the WordPress posts structure and all the advantages that implies, or at least doesn’t integrate the terms into posts as well as WP-SNAP! does. For me that’s important, so I am sticking with the method I’ve written here. Yet, all in all, a plugin that definitely deserves your attention if you want a glossary for your WordPress site.
12 Comments
Hi Shanta,
I need your help for following:
Ubernmys - I had installed this plugin many time, but it does not pop-up abbr or acronymn defs. I had written to Joel also, but could not hear anything from him.
Could you advice me of ‘what could be the possibility of the plugin not working here?’
DG…
O.K another issue is with wp-snap. When I activate this plugin SK2 and Akismet etc. plugins gets de-activated.
I have created a page templte and with the following “. 165 being cartegory ID. But I receive an error while viewing the page Error:
Warning: Invalid argument supplied for foreach() in /blog/wp-content/plugins/wp-snap.php on line 196
WordPress database error: [You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near \') AND `post_id` = `ID` AND `post_status` = \'publish\' 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` = \’publish\’ AND `category_id` = \’165\’ ORDER BY `post_title` ASC
Can you look at it and advice.
DG…
DG — Your best bet may be to contact the authors of the plugins. I’m afraid I’m not familiar enough with them to answer your questions. By the way, I also use SK2 and Akismet; WP-SNAP! didn’t cause any problems.
Hello Shanta,
I just wanted to thank you for this. I found a link to your page on the WP forum, and followed your instructions and now have a great Glossary on my site! This is necessary for me as it contains a fair amount of technical 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 question though, if I might. I’m curious. You say to create both a page for the glossary and a category. I’m not sure what you mean by that? The way I’ve done it was to create a category (as it happens with an ID of 22), and then a template for it calling category-22.php. Is this what you meant? If not, what did you mean? No biggie, it’s working for me, just curious.
Cheers
Nic
Hi Nic — Glad you found it useful. If I understand you correctly, you\’ve created a unique category page for your glossary, which sounds like a good idea too. I created a Page (i.e. with a capital P) because I wanted to take advantage of the page navigation tabs in my WordPress template.
I don’t have any category.php file in my theme (3k2); what could I do to have a Glossary?
Thanks
Claudio — You don’t need to have a category template to make this work. However, if you don’t use category.php, then you’ll need to assign all posts you want included in the glossary to a single category ID, and then use the function call to display content for this category on a Page. This is in fact the procedure I describe here (the Musil theme I am currently using doesn’t have a category template either).
Hi,
Just found this site, and would appreciate some insight on how to set this up on my pages. I may have missed something, but step 2 in the above instructions doesn’t go into much detail, how exactly does one paste the code into a page? I’m a PHP newbie, so please be gentle. ;-))) Thanks!
Marc–Luckily (for both of us), you don’t need to be a PHP expert to make this work. However, you do have to know a little bit about how Pages operate in WordPress. The easiest approach is to modify either index.php or page.php as follows, and save the new file as glossary.php. This example assumes you have predefined a glossary category with a category ID of 5. Hope this helps:
<?php
/*
Template Name: Glossary Page
*/
?>
<?php get_header(); ?>
<div id=”content”>
<?php echo wp_snap(’5′); ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
It’s a nice idea. Where does it give benefit, where a simple sitemap and category list does not?
Wonderful question, Scott. I don’t like the idea of categorizing my notebook entries; they are topics that I am interested in, but still don’t know very much about. That means it’s a little early to peg a category, or impose a structure like a sitemap. But I do want to find them. For me, there’s no better way to do this than to automatically link to these entries any time I mention them elsewhere in the site (using Ubernyms). As for alphabetizing? Yes, that’s arbitrary, but no more arbitrary than revserse chronology.
Shanta —
WP-SNAP! works with Pages again. :)
3 Trackbacks
[...] Yeah, the glossary thing is kinda neat. I wish I could claim it as my own, but it’s not ;) Shanta describes the technique here: shantarohse.com/wordpress/create-a-glossary-for-your-wordpress-site [...]
[...] […] Make that two steps forward, two steps back. In the current version of WP-SNAP! (0.61), plugin author Nathan has removed the option to pass a category number directly to the […] Create A Glossary for Your WordPress Site | Shanta Rohse [...]
[...] to announce the immediate release of our first WordPress plugin: IMM-Glossary. […] Create A Glossary for Your WordPress Site | Shanta Rohse on December 13th, 2006 at 7:57 pm [...]