WP-SNAP! WordPress Plugin
What Is WP-SNAP!?
WP-SNAP! (WordPress System for Navigating Alphabetized Posts) 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. Since it is said that a picture is worth a thousand words, here’s a screenshot of WP-SNAP! in action:

WP-SNAP! offers three different navigational styles and integration with both custom permalinks and the WordPress loop. Plugin options can be managed both site-wide and on the template itself with results either restricted to one category or broadened to include child categories as well. The clever web developer should have no problem seamlessly integrating WP-SNAP! into their latest project. Options have also been added to allow the customization of css class names and the appearance of html mark-up.
How To Configure WP-SNAP!
- Click on the link to the right to download the WP-SNAP! WordPress Plugin, extract it and upload it to your WordPress Plugins folder on your site.
- Activate the Plugin from the WordPress Administration Plugins tab.
- Edit the category templates your Theme uses, such as category.php, and add the following code above the start of the WordPress Loop:
<?php if (function_exists('wp_snap')) { echo wp_snap(); } ?> - Copy the CSS example below and paste it into your WordPress Theme stylesheet (you can style it better later).
- Upload the files and refresh the category page on your WordPress blog to see it in action.
- For further customization, go to WordPress Admin > Plugins > WP-SNAP! Settings. The available settings allow you to make site-wide changes to things like the alphabet, the navigational structure, permalink structure. You may also change the categories to be displayed and the menu navigational structure by passing variables as a query-string to the plugin like so:
<?php if (function_exists('wp_snap')) { echo wp_snap('arguments'); ?>There are currently four possible arguments: Category (‘cat’), Include Category Children (‘child’), Navigational Menu Style (‘menu’), and First Load (‘firstload’). Category must equal a category number from your WordPress installation, Include Category Children must equal true or false as to whether to include child categories (the default value is false), Navigational Menu Style must equal a number between 1 and 3 (corresponding with the three navigational styles offered in the admin options panel), and First Load must equal ALL, NONE or RECENT and will affect how WP-SNAP! displays posts/tags when it is first called on a template. Note that if RECENT is selected, the number of recent posts/tags to display can be controlled from the admin options page. For instance, to create a navigational menu for all posts in category 15, including child categories, using the default menu navigational style, and displaying recent posts on first load, WP-SNAP! would be called like this:
<?php if (function_exists('wp_snap')) { echo wp_snap('cat=15&child=true&firstload=recent'); } ?>To create a navigational menu for the current category, excluding child categories and using navigational menu style 3, WP-SNAP! would be called like this:
<?php if (function_exists('wp_snap')) { echo wp_snap('menu=3'); } ?>To create a navigational menu for all categories, using default navigational menu style, WP-SNAP! would be called like this:
<?php if (function_exists('wp_snap')) { echo wp_snap('cat=all'); } ?> - Test it out and enjoy!
Note: For the Plugin to work, you must have access to edit your WordPress Theme files. You must also have a category.php template file in your WordPress Theme. If you do not, you can create one following the instructions on the WordPress Codex for creating a category template file.
CSS Styling
It should be noted that this plugin does not inject any css styling information, so it is up to the user to add the appropriate class information to the WordPress Theme css stylesheet. Here is some sample code to get you started:
ol.snap_nav {
display: inline;
float: left;
clear: both;
list-style: none;
}
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 {
cursor: text;
}
ol.snap_titles {
clear: both;
display: block;
border: 0;
list-style: none;
}
Feedback
This plugin thrives on user feedback. Praise, ideas, and bug reports are all welcome. Use the comment form below to let me know what you think. Please keep in mind that I am not paid to work on this plugin and that delays between updates can and will occur. Please do not post questions about when the next update will be released. I appreciate your enthusiasm, but your comment will be deleted. If there is a significant delay between releases, I try to post a timeframe of when the next update can be expected.
Thank You
My thanks to Lorelle VanFossen for reviewing my plugin and allowing me to reuse her instructions on this page.
Change Log
- 08.2010.05 Version 0.9.4
- Rooted out a couple more bugs
- 08.2010.01 Version 0.9.3
- The bug hunt continues!
- 08.2010.01 Version 0.9.2
- Fixed more bugs
- 07.2010.31 Version 0.9.1
- Fixed several bugs with the database call
- 07.2010.30 Version 0.9
- Improved international character support
- Added warning if database is empty
- 02.2009.20 Version 0.8.6
- Fixed bug with posts beginning with misc. letters on sites not using fancy URLs
- Fixed bug with adminstrative menu
- 06.2008.10 Version 0.8.5
- Added international language file support
- Changed the method for passing data to the plugin
- Tracked down bugs
- 06.2008.08 Version 0.8.4
- Made the plugin compatible with WordPress’s new tagging system
- Corrected problem with listing recent posts
- 04.2008.03 Version 0.8.3
- Fixed a small — but significant — typo
- Moved the administrative submenu to plugins.php
- Added the ability to display All/None/Recent posts on first load
- 12.2007.02 Version 0.8.1
- Fixed incompatibility with PHP 4
- 11.2007.28 Version 0.8
- Added support for fancy URLs
- 10.2007.04 Version 0.7.3
- Fixed error with WordPress 2.3 database call
- 09.2007.28 Version 0.7.2
- Made database call compatible with WordPress 2.3
- 06.2007.02 Version 0.7.1
- Fixed error with database call
- 05.2007.30 Version 0.7
- Fixed issue preventing the display of more than 10 posts
- Fixed issue with sorting uppercase/lowercase post titles
- Restored ability to pass a category to the plugin
- Added ability to include category children in returned results
- Added ability to display all categories
- Added ability to change navigation style when calling the plugin
- Added support for Gengo (hopefully)
- 05.2007.12 Version 0.6.2
- Restored the ability to exclude first words from being alphabetized
- Cleaned-up some instructional text in the options menu
- 01.2007.21 Version 0.6.1
- Fixed a minor error with the $wp_snap_category variable
- 01.2007.20 Version 0.6
- Rebuilt the entire plugin to be better, stronger, faster
- Changed how results are displayed; plugin now plays well with the WordPress loop
- Removed option to pass a category number directly to the plugin, making it incompatible with Pages (feature to return if requested)
- Added nonce protection to the admin options panel
- Added option to group posts beginning with a number under ‘#’
- Fixed unencoded ampersands
- 09.2006.20 Version 0.5.4
- Updated WP-SNAP! to ignore posts with post-dated timestamps
- 08.2006.02 Version 0.5.3
- Fixed an error that affected certain navigational menu styles
- 08.2006.01 Version 0.5.2
- Updated alphabetization to accomodate accent marks; still needs refinement
- Fixed a logic error with the post title sort loop
- 06.2006.07 Version 0.5.1
- Squashed some bugs in the new ignore filter
- 06.2006.06 Version 0.5
- Words can now be filtered from the alphabetization process from the WP-SNAP! admin options menu
- 06.2006.01 Version 0.4
- Added ‘#’ to catch category entries beginning with non-alphanumeric characters
- Tweaked the code here and there
- Fixed the WP-SNAP! plugin url on the admin options page
- 05.2006.13 Version 0.3.1
- Fixed the url structure of the navigation when used on a Page
- Added ‘apply_filters’ to the post excerpt
- 05.2006.08 Version 0.3
- Plugin no longer displays excerpts for password protected posts, if the viewer is unauthorized
- If there is no excerpt for a post and excerpts are turned on, plugin now creates an excerpt from the post content
- Fixed a typo
- 03.2006.29 Version 0.2
- Added the ability to pass a category number directly to the plugin, making WP-SNAP compatible with Pages
- 03.2006.29 Version 0.1
- Initial Release
Hello Nathan–
I was looking at using your plugin to create an alphabetized archive page. Unfortunately, the plugin generated 4 “headers already sent errors” and was then inaccessible from the Plugin management page. I had to delete it and never got the chance to take it for a spin. Offhand, do you know what might have caused the errors? The warnings were on lines 11, 12, 13, 14. Comments. I removed the comments, but the same error was generated. WP 1.5.2. Any ideas?
cheers
SAM :)
Thanks! There was indeed one space after the closing ?>. Thanks for your quick response!
Sam —
After doing a bit of research, it seems that header errors are most likely the result of “spaces, new lines, or other garbage before an opening <?php tag or after a closing ?> tag.” My guess is that you copied and pasted this plugin into a new document and accidently left extra spaces in the document. I suggest that you re-download the plugin by right-clicking on the above link and saving it to your drive. Thank you for your feedback!
Where i put the plugin code?
archive? single post?
Every attempt to activate the plugin returns a blank page for my blog. I have downloaded several times to avoid the problem you mentioned above.
Very cool. Just what I was looking for. Going to use it for software reviews for my friends and Dad. They are always asking me what software does this or tha, or what a particular piece of software I am using. This will work nicely on the cat page I made. Thanks!
Roberlan — for most themes, you would place the code in your category.php file. That’s the only way to get it to work in it’s default mode. But it’s really up to you. Where do you want your list of post titles to appear? It should work just about anywhere, as long as you pass a category number to it.
andre — If you would like me to help you resolve the issue you are encountering, you will have to be a little more specific. How are you trying to “activate” the plugin? Do you mean from within your WordPress admin interface? Or when you place the wp-snap() function on the page? In which file are you placing the function? Where in the file are you placing it? If it’s one besides category.php, you’ll have to pass a category number to it.
z — Thank you very much for the feedback. It’s great to hear that someone has found use for this!
nateo
I haven’t been able to get past activating in the admin interface. I dl’ed the wp-.phps file upload to my plugin directory rename wp-snap.php. Then go the the admin interface click activate then I get blank page. if I remove the wp-snap.php everything goes back to normal. I’m running WP 2.01 on a unix box
hey nate, thanks for the answer, but in my wp installation (wp2.0.2) i don´t have “category.php” file. I can´t figure it out where to put the code…
Anyway, thanks for the answer
:)
andre — Off the top of my head, my first thought is that you’re having a conflict with another plugin. It would be helpful to know if you still get the blank page when you turn off all other plugins. If the blank page goes away, if you could let me know what plugins you’re using, I’ll see if I can figure out what the conflict is and fix it! Thanks!
Roberlan — The “category.php” page would be in your theme files. So you’d go to /wp-content/themes/default/ to find category.php.
nateo I found the conflict I think it was with a plugin caled book review when I removed that wp-snap activated fine. Is a horizontal list an option?
andre — I’ll look up “book review” and see if I can figure out why it’s a conflict. Thanks for the heads up. Yes, the list can be made horizontal, you just have to add some code to your style.css file in your theme. Unfortunately, a css tutorial kind of goes beyond the scope of this plugin, but I did provide some sample css rules above. You’ll probably find that those rules will work better if you append the div id or class in which they are contained. For instance, if your php code looks like this:
Then change the above styles to begin like this:
Hello,
I am trying to organize a list of museums on a protected install of WP that I use to organize the notes for my doctorate. I want to display a single category of entries (cat # 15). I tried the syntax that you post …
… but it did not work. What am I doing wrong? How can I get it to work because this is perfect for what I am to do?Hello Thad —
You didn’t mention in your post how WP-SNAP! failed, so it’s difficult for me to suggest a solution. Is your problem that you can’t isolate it to a single category? Or that it’s not working at all?
If you are using the default theme, go to your archive.php file and starting at line 32, change your code to something like this:
That should get WP-SNAP! to display for the correct category, but you’ll probably want to clean things up a bit after that — maybe add a div container around it, include more html code in the else statement so that you don’t get full post entries displaying for category 15.
Hope that helps.
nateo -
Thanks! That fixed it! Cheers!
Sorry about not describing the problem in too much detail …
But, thanks for the solution!
Hello … today, I got an error message that I had not gotten since I started using it. Before today it had worked fine but today I get this error when I click on the category link -
The other odd thing is that it works fine if I click on a letter (which are still displayed on the page below the error).
Any help would be appreciated.
Sorry about posting too fast … but I figured out what broke the script. The last post that I had entered was started with ‘The Grove’ and evidently the quote breaks the script because it does not know how to handle it.
Just wanted to let you know, cheers!
Thad — Thank you for the heads up. I’m not sure what the best way to handle this is. Any suggestions?
Rhine — WP-SNAP doesn’t automagically create excerpts like WordPress does. It actually pulls the excerpt from the excerpt post field. So, if you didn’t write an excerpt, nothing shows up. I’m not sure that this is the best way to go about this, because I’m sure many people make use of the auto excerpts WordPress creates. I’m sure it’s a fairly easy fix, let me think about it.
Hey Nate, AWESOME plugin. I’ve been tweeking with it this morning but I have one issue I can’t seem to resolve myself. I checked the box “Show Post Title and Excerpt” but only the post title shows up. Am I missing something?
Thanks
WP-SNAP! has been updated to version 0.3. The plugin now creates a post excerpt from the post content if the post’s excerpt field is blank.
Nateo – Thank you for creating such a useful plugin. I am using it to create a glossary on a Page. However, 1) when I add a new entry, it bumps the previous entry off the Page (so that there is only one), and 2) clicking on the alphabet menu brings me to the category page. Any suggestions?
shantarohse.com/glossary/
Shanta — Beautiful site! I have updated the plugin to version 0.3.1, fixing the error with the urls linked to the navigational menu. I’m afraid that I cannot reproduce the error you are having with new entries bumping old ones off the Page. There’s no reason that I can see for all the entries under a give letter to not be displayed. Looking at your site, there appears to only be one entry per letter so far — are there actually more that cannot be seen?
Nathan – Thanks for the quick response. v0.3.1 does the trick! The dropped posts is no longer a problem either – I think it was an artefact of the urls linking to the category page. It just looked like they were dropped. Great stuff. Thanks for the complement about the site – lots of the credit has to go to the Musil theme created by Florian Kriener.
May I ask – is it possible to add the more tag to the excerpts?
Shanta — You are welcome. If when you say “more tag” you mean that at the end of the excerpt it would say “[More]” or “[Read More]” etc. then, yes, that is possible. Aesthetically, that seems to be a little overkill for me since the title itself is a link to the full article, but let me tell you how you can “hack” the plugin to get what you want. Open up the plugin and change line 350 from:
To:
Obviously, you can change the word “[More]” to say whatever you wish.
Thanks once again Nathan. And you are quite right about the aesthetics the more link. But it was nice to be able to try it out!
Hi,
I have saved wp-snap plugin. But at first attempt, it generated and rendered my dashboard as non-working. I could not even logged out. I had to then click back on the browser and de-activated plugin. Only then, I was able to logout of do other things.
I had then checked wp-snap.php and found a line space before the closing tag. And after saving, when I activated wp-snap, some of my existing pluging say for e.g. SK2, Akismet etc. were de-activated.
And after that, I created a category “Glossary” and page template, inside the template, I entered . “165″ being cartegory ID.
But I am receiving an error while viewing the page
Can you please look at and advice me to get this working.
DG…
Hi DG — I’m sorry to hear that you’re having difficultly getting the plugin to work. I suggest that you re-download the plugin by right-clicking on the link above and then renaming the file as my instructions advise. Copying and pasting the code into a new document is really not a good idea.
Hi Yves — If you right-click on the document, save it to your desktop, then simply rename the file, you should not have to clean anything up. I like providing the file as a phps because it allows those that want to look at the code before they download the plugin to do so. But, perhaps you’re right. Maybe I should provide a zipped version of the file as well. Making the change now. Thanks for your input.
May I suggest that you provide a direct link to the mere simple PHP text file. It is rather painful to cleanup the phps file to use it.
With Opera, I finally got to produce a text file but with a bunch of additional CR-LF which break the comments into syntax errors.
It seems it will be what I need, but it will take some time before I can even try it.
Yves
DG — Is this a category or a page? If it is a category, you do not need to input a category number (ie, 165), it will pull content from that category automatically. Do you have any posts in this category yet? If you do not, the plugin will not work right.
Hi Nateo,
First thanks for your reply. I just downloaded plugin zip file. And re-uploaded and activated again.
But when I go to page view, I am still receiving the followin quoted error:
Just to make the things easier for you, I have inserted this code in page template .
Here is the page link: http://www.roks.xmgfree.com/blog/glossary/
You can see what error is displayed, please advice me, I want to see it up.
Regards, DG…
Nateo – Please ignore my last post.
After activating wp-span plugin, I did the following.
1. Created a new category called “Glossary” with ID 165.
2. Created new template “Glossary-t” and inside this, I have entered the code as mentioned above in useage for e.g. .
3. Then I created a new page using the template mentioned at step 2. and named it “glossary”.
So, the link : http://www.roks.xmgfree.com/blog/glossary/
is of a page Glossary.
DG…
DG — Do you have any posts in category 165 yet? If you do not, the plugin will not work correctly.
Great Plug in Nateo, took me a minute to clue into how to install it…
Tom — Thanks for the feedback. As you can see, your last comment got caught in the gap between the switchover from my old host to my new host. I was about to respond to it when you posted — it sounds like you figured out how to get the plugin to work? Glad to hear it!
I did, it works great. I downloaded a visibility toggle plugin http://wordpress.org/support/topic/21171 as well so the new posts to the glossary don’t show in the categorys or at the top of the blog, rather they are a link.
here it is working on my page: http://www.digitalconversations.net/glossary/
One thing I noticed, although not really a big deal, but since I am pretty picky about the html, I think I may change the list tags to definition tags. If there is any difference as far as search engine optimization goes for this…which I will have to look into.
Great Plugin Nathan, thanks again.
i’ve just downloaded the “Latest Release,” but it identifies itself as v0.2, with the changelog last updated 03.2006.29. Did you neglect to update the versioning in the code, or is your link above a bit stale?
Tom — Let me know what you find out with regards to definition tags. If there is an SEO benefit, I’d be willing to look into making them an option in a future version of the plugin.
C — Funny thing, that. I was showing off my new site to someone today and noticed, to my horror, that very mistake. Unfortunately, there was nothing I could do until I got home. It’s all fixed now, however. Sorry for the confusion!
Thanks! One more heads-up… looks like you’ve recently changed your directory structure around. The Plugin URI in v0.3.1 is set to http://www.nateomedia.com/technology/wordpress-plugins/wp-snap, which 404′s, so clicking the link from one’s Admin Plugin page is no fun :(
Hi Nathan,
I tried to google this but haven’t found any information. I tried some define: keyword searches in google, and it doesn’t seem to favor one kind of syntax over another, although I can’t really make a conclusion as my experiment wasn’t exactly science based.
I made a post in an SEO forum. I’ll let you know if I find out anything else. I might make the change myself to my site just for accesibility purposes, and because I like the smell of a nicely marked up document. ;)
I’ve updated WP-SNAP! to version 0.4. Posts beginning with a non-alphanumeric character (i.e., a quotation mark, ampersand, percentage symbol, etc.) can now be incorporated into a category calling WP-SNAP! I’ve also streamlined a little bit of the code using regular expressions and updated all the links within the plugin to point to the new permalink.
Hello I have successfully installed your plugin but cannot get it to work. When I tried to put into my category-8.php it worked but the top would be all white and at the bottom there would have the your navigation system then below that posts in that category. If I could get it to know make a blank white page, and have the navigation shown at the the top it would be great.
I also tried the other way you described. By making a glossary page and then having the syntax in a basic page template. When I tried to view it would give me this different error :
Warning: Invalid argument supplied for foreach() in /var/www/users/luna6/lunapark6.com/wp-content/plugins/wp-snap.php on line 204
WordPress database error: [Got error 'brackets ([ ]) not balanced’ from regexp]
SELECT `post_title`, `post_content`, `post_excerpt`, `ID`, `post_password` FROM wp_posts, wp_post2cat WHERE left(`post_title`, 1) RLIKE ‘[]+’ AND `post_id` = `ID` AND `post_status` = ‘publish’ AND `category_id` = ‘’2′’ ORDER BY `post_title` ASC
any help or tips would be helpful!
Oops sorry about the bad typing…basically when I added your recommended (echo wp_snap) command into the category-8.php file it would work but leave a huge white gap on the top of the page and would have to scroll down to see the your navigation system and first post.
The other way was pasting your command, specifying a specific category in a glossary page template…but when I tried to view it I got that big long error about brackets. thanks in advance for any tips. My website you can see in the error output.
Well I got rid of the error but with a blank glossary page the navigation system sits at the bottom of a white page. What kind of line can I use to make sit at the top the page?
Ki — If I understand your problem, WP-SNAP is generating the menu correctly at this point, but a lot of white space is appearing above it? That sounds like a CSS issue. You probably need to alter your margins or padding around the menu using a div or class selector. I speak to this sort of issue in some of my comments above, unfortunately I don’t really have a lot of time to give a more thorough tutorial on the subject.
The error you received earlier was because WP-SNAP! was not finding any content in the category you called it from. I really should make the plugin fail more gracefully than that. My apologies.
Nathan no problem. Already appreciate the work you have done no the plugin. I am going to spend today looking at the CSS file and see if I can get it to show. Thanks for your input.
Nathan one last question – is it possible to have your plugin ignore the word “The” ? A lot of films, books, music begin with that and would make it more balanced to ignore the first word it begins with “The”
Ki — Is it possible? Yes. Is it simple enough so that I could walk you through how to hack it right now? No. Is it a good idea for a future update of the plugin? Yes.
I also would like to update the plugin to give the user the option to ignore titles beginning with a single or double quotation mark. When I sit down to work on the next version, that’s at the top of my list. Thanks for pointing out that “the” should be optionally ignored as well.
Excellent. I was going to ask about ignoring “The” as well. I’m looking to use WP-SNAP to navigate cocktail recipes, many of which take an initial definite article by tradition. Of less use to me, but handy for others, would be ignoring A and An. Perhaps the best option would be to allow a user-configured ignore-list in the prefs, instead of hard-coding anything, since I’m sure every language and discipline has its own unique equivalent of Chicago Manual of Style guidelines on alphabetization.
Is there a parameter I could pass to wp_snap within a single.php page which would return the snap_nav, but no title listing? I’d like to be able to drill-down into a page like this one while still providing the alphabetical navigation strip. I suppose one could hide the titles via CSS, but it’d be messy, and consume extra bytes.
Thanks again for all your work on the plugin — it enables so many new uses for WordPress!
Nathan,
I hope you can help me, as I would love to use your plugin. My site is bilingual and I am using Gengo 0.7 to manage my translated pages and posts. So, how could I use WP-SNAP! to generate a glossary for each language?
Currently, I am using
to generate my glossary list because (along with Gengo) it returns only the posts in the current language, while WP-SNAP! returns all the posts in all the languages. But as the glossary grows, I really need the neat pagination that WP-SNAP! provides.
Thank you.