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 the Plugins > WP-SNAP! panel and change the alphabetical structure to something different and click Update Options. 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
- 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
Comments
Download The Latest Release
View The Code
Make A Donation
If you find this plugin useful, please consider making a donation. It's a great way to say “thank you” for all the hard work that has gone into its development.
Frequently Asked Questions
-
When will the next version of your plugin be released?
As soon as I find the time, I will update the plugin and release a new version. I understand how frustrating it can be to be so close to having the perfect Wordpress installation only to be held up by a plugin that just needs a little more work to be exactly what’s needed. However, please remember that I am not paid write this plugin and that, like you, I have a family and responsibilities that extend far beyond this little piece of code. I really appreciate your enthusiasm, but if you wish to reap the benefits of my freely given labor, then you must be satisfied with doing so on my timetable. Otherwise, if you simply cannot wait, you are more than welcome to modify and extend the capabilities of my plugin yourself.
-
Why do the results WP-SNAP! returns look funky? Why is it numbering every item?
A web page is composed of two parts: a document containing HTML code and a document containing styling code (known as a Cascading Style Sheet, or CSS for short). Because WordPress templates can look so drastically different from one another, I have intentionally avoided injecting any CSS information into WP-SNAP! However, I have included several ID selectors (that can even be modified from within wp-admin) that should allow you to style WP-SNAP! to look however you’d like. Those numbered lists? You can turn them off. I do ask that you try to refrain from asking me CSS related questions — while I would love to help you, my time is limited. If you would like to learn more about CSS, I suggest visiting A List Apart or Vitamin.
-
I tried using your plugin, but it just won’t work. What am I doing wrong?
Unfortunately, I don’t have the time to troubleshoot every installation of this plugin. However, if you believe you have discovered a bug, I encourage you to post a comment to my website and I will reply as soon as I can. I do request that you be as specific as possible when asking for assistance. Please provide a detailed account of the steps you took that resulted in the error you encountered so that I can try to reproduce it and more quickly deduce how to fix it.
Ki — Nice idea. No guarantees when it will happen, but I think that would be an excellent feature to include. I’ve added it to my list. Thank you for your feedback!
If you’re going to use WP-SNAP! as your navigation, you could edit your single.php file to have a “Return to listings” link and use $_SERVER['Request_URI'] to create the address link.
November 8th, 2007 at 9:25 am
Hello. I followed your instructions to use this plug-in very closely, and have tried it twice. I am using wordpress 2.3.1.
I uploaded the plugin, activated it, then added the
[?php if (function_exists('wp_snap')) { echo wp_snap(); } ?]
to the top of /wp-includes/category.php and uploaded.
I added your generic styles to /wp-content/themes/style.css.
When I go to “write” or create a new entry, I get a php header already sent (by category.php) error after I submit, or hit “publish”. It does make the entry on the main page, but it’s not sorting anything alphabetically.
As soon as I de-activate the plugin and remove the additions to the two files (style.css, and category.php) everything returns to normal.
Any help is appreciated. My goal is to have all categories, entries, etc to be listed in alphabeticall order.
Thanks!
Jeff
November 8th, 2007 at 11:18 am
Jeff — Your description of the issue you’re encountering isn’t making any sense to me. I’d like to email you about this issue so that you can send me your category.php file. Can you please include your email address in your next comment? It is not published and it will only be seen by me. Thanks.
November 8th, 2007 at 11:37 am
My email address was included in that post Nathan. Just as it is in this one.
Thanks.
November 8th, 2007 at 11:38 am
Hi Nathan,
Cool plugin! Very customizable! But like many things, each individual wants his own settings (and even better, cause what would the world be like if we were all the same..) So here’s my config issue:
I want to ‘call’ the index from my sidebar. I have only one category and made it default (must be if there’s only one). I placed a execPHP widget in the sidebar (I tried several with the same result) and added the code
to it.Now the index shows me the letters which have a post in it (only a few so far) and I can click on them but then nothing happens. I stay on the homepage. When I hover over a letter in the index, I see /?snap=x added to the domain (where x = the letter I hover) while I'd expect /categories/mycategorie/?snap=x after the domainname.
Any idea? Is this because it's executed from a widget in the sidebar instead of a post?
Kind regards,
Léon.
November 23rd, 2007 at 5:02 am
Léon — You shouldn’t expect it to switch your URL to something different, because that’s not what it does. WP-SNAP! works on the page currently being viewed and will change the results of the Wordpress Loop on that page. If your sidebar follows your Loop in the php code, then it won’t even do that.
November 23rd, 2007 at 9:24 am
Nathan,
Thanks for the prompt reply. What I understand from your answer is that it’s not possible to get an index of a given category from a page but only from a post. Is there a way to get it to work from a page when there’s only 1 category?
Thanks.
November 24th, 2007 at 4:05 am
Léon — You absolutely can get the plugin to work on a Page. When you click on a letter, the results are displayed in the Wordpress Loop on the same web page as the navigation. It will not redirect you to some other URL. After the results are listed, clicking on one of the entries should then redirect you to the URL of that post.
As I hinted at before, I suspect your issue is that you are calling WP-SNAP! after your Wordpress Loop. It’s the same issue Jeff above had. Restructure your theme so that your sidebar comes before your Loop.
Unfortunately, I do not have the time to solve this issue for you. It does not sound like the plugin is malfunctioning, but that you do not have much experience making web pages. Wordpress has great support forums for answering those kinds of questions.
November 24th, 2007 at 9:37 am
Hi again.
Dear Nathan, The The problem as i told before was not about the plugin. Just about searching big amount of data.. when the response time off or something else, it crashes. it’s not about the digits. i tried plugin via 100-200 and more, it works good.. but if there are much more posts like 700-1000 or much more, it crashes. i think it is about the server/response time or db stuff.. huge data makes slower everything. :) thanx again for a really good plugin.
November 26th, 2007 at 7:55 pm
Newbie — Ah, well, my plugin uses the Wordpress Loop to display data. So, if you’re having problems displaying 700 posts on a single page using WP-SNAP!, I’m guessing that you’d have the same problem if you tried to display 700 posts on a page without my plugin running. It’s a Wordpress problem, really. However, what could help is if there was a paging system. WP-SNAP! doesn’t have a paging system at this point, because no one has previously reported an issue such as yours. I don’t think there will ever be a way to display 700 posts on a single page, so would a paging system be something you are interested in?
November 26th, 2007 at 11:17 pm
I would love a paging system as well. My blog is getting up there with posts and I can see where it would help.
November 28th, 2007 at 12:21 am
Been waiting for the fancy url’s for a while, so I was glad to see the update. For some reason when I go to update the options, though, I just get a blank page, and the changes aren’t saved. Any suggestions as to what may be causing this?
December 1st, 2007 at 7:42 am
Shane — Assuming that you are using Wordpress 2.1.x or higher, I’m guessing that it’s a conflict with another plugin. Try turning off everything else and see if you still have problems. If it is another plugin, if you let me know which one, I’ll take a look at it.
December 1st, 2007 at 9:27 am
Tried to to update to .8 and when activating fancy url i get this error:
Fatal error: Call to undefined function: str_split() in /home/website/public_html/wp-content/plugins/wp-snap.php on line 499
December 2nd, 2007 at 1:51 pm
Ki — Thanks! I didn’t realize it, but str_split is PHP 5 only. I’ll revise to make it work in PHP 4.
December 2nd, 2007 at 6:12 pm
Hello Nathan,
Just letting you know I tried .8.1 and after activating fancy url and then click on a letter I would get this error message :
Parse error: syntax error, unexpected $end in /home/user/public_html/wp-content/themes/blue-zinfandel-10/404.php on line 45
works fine if fancy url is not checked…
December 3rd, 2007 at 12:45 am
Ki — If you switch to the default theme, do you get the same error?
December 3rd, 2007 at 1:11 am
Nathan hard to say because all the custom page indexes I made reside in that particular theme. I will try to set up the same in the default theme and see if it works. thanks,
Ki
December 3rd, 2007 at 10:02 pm
Ki — The error you are reporting is with your theme, not the plugin. The two are incompatible in some way. If you’ve customize the theme on top of that, there’s really no way for me to know what that incompatibility is without you doing further testing. To start, just stick the php call to WP-SNAP! on the index page of the default theme (before the loop), switch themes for a second and see if the default theme works. It should. That will tell us definitively that the problem is with the theme you’re using, not the plugin. (Although, I’d love to know what the incompatibility is still — if I can prevent it, I will.)
December 3rd, 2007 at 11:00 pm
0.81 did the trick. Thanks.
December 5th, 2007 at 3:40 pm
Pages: « 1 … 10 11 [12] 13 14 … 18 » Show All
Leave a Reply