How I do a semi-automatic glossary on WordPress
Using a plugin and a simple process, you can easily add a Glossary to WordPress. You'd think that there would be a plugin out there by now to do this. As a matter of fact, there seem to be a few, but none of them really do the job right AFAIAC.
If I could and ever did write it, I think version 0.01 would be based on this requirements.
- Able to add terms through a friendly management page.
- Able to add terms by using shortcodes in posts, on the fly. Something like this {{term:definition}} that would actually enter that into the database.
- Have the ability to only link the first instance of the word in a page.
- The ability to prevent autolinking with a shortcode. For example, if you have defined the word Genus, you should be able to do this !!Genus ((The use of !! is arbitrary, it could be anything else that is unique so the plugin can parse it --or not accordingly.)) so it does not automatically link.
There is no plugin out there that does all this in addition to the expected Glossary services like a list of terms alphabetized and paged and all that. So the way I am handling this for now is with a plugin and a manual process. The plugin is SEO Smart Links, which I think could easily be converted to do all this by itself but I'm hesitant to try this. I want to get exactly what I want down in paper first before I try to hack any code.
SEO Smart Links allows you to define a term, or group of terms that will automatically link to a given URL. It is really great and the admin panel features are well polished.
In theory this is how you add a new term:
- Create a post for the term which you want to define.
- Get its URL. If you're using pretty permalinks then you should be able to guess the URL in advance.
- Next go to the SEO Smart Links admin panel and define the term you want, and point it to the link you got on step two.
- Save it and you are done. Notice the many different options that SEO Smart Links gives you.
If you know your permalink structure, you can add as many definitions to the SEO Smart Links panel as you want all in one motion since you can guess the URL in advance. Then you go through and fix any broken links. After you've added a number of these you probably want to have them displayed on a nice listing along with other words that belong to your glossary.
To do this, you can create a new page, called "Glossary" or whatever you want and either apply a theme template to list the terms alphabetically and paged, or you could just use php-exec to call the logic to display the terms. Either way you'll have to do a good amount of testing and tweaking until you get it all right.
I'm currently on the first part of this project, I have defined a number of terms and have the posts ready to go. When you click on a term that I've defined, you will be taken to the page which defines the term. After you've seen the definition, you'll find a link to the main glossary from the bottom of the article or on a conditional sidebar. I haven't decided this part yet.
I will try to get the automatic Glossary page listing by the time I have 25 terms defined. The definition post should be categorized as a glossary term, or according to your own Glossary category; this will help you maintain regular SEO smart links mixed up with the single purpose Glossary of terms link.
edit: I think I figured out a better way to do this, I'm working on it and it seems much simpler. See this post.