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
great plugin. but i got a few request or recommendations.
1 is that i would like to see pagination support. listing like a 100 items will make a very long blog list for me. Also pagination support on the first load recent posts would be nice.
Another thing that would be cool is to be able to exclude some pages or categories.
ok, thnx.
Doesn’t seem to work with custom content types… That’s too bad, because everybody will be using that feature when WP is used as a CMS over a blogging tool.
Would it be possible to add custom post types to the alphabetical index?
This actually does work very well with custom post types with a hack, would be nice to integrate this into the codebase:
line 177
function wp_snap($snapquery = '',$post_type='post') {line 219
$results = $nav->navigation($post_type);
line 244
function navigation($post_type) {
line 346
$where .= " AND (post_type = '$post_type' AND (post_status = 'publish'";
Everything seems to work fine, the menu is showing what letters i have but when i click on a letter the page refreshes and it just shows me the same post on the last page.
Does this not work with pagination? My theme still shows 14 pages in the pagination although the plugin dont seem to paginate.
Eric — No, there is no pagination.
Jay — I have no idea.
Enrico — Thanks for the feedback.
Danny — Not at the present time.
http://theforgottenlair.net/category/anime-reviews/
Hi, I’m having trouble at the link above, in that whenever I place it at the top of the page, the a-z list do not become links but are simply text. When I place them on the bottom is when they become links. However the GREATEST problem is that they do not sort the posts. They simply refresh the page.
My category-9.php looks like this:
get_option('thesource_homepage_posts'),'paged'=>$paged,
'category__not_in' => get_option('thesource_exlcats_recent'),
); ?>
Thank you in advance…
The code you’ve included doesn’t explain how you are using the plugin, so there is little I can say. However, I don’t really have the time to troubleshoot installations of the plugin so, unless you think you’ve encountered a bug (and can explain to me how to reproduce it), there’s not much I can do to help. Good luck.
Hi,
I have the same problem like many others.
Warning: preg_match() [function.preg-match]: Compilation failed: missing terminating ] for character class at offset 4 in /chroot/home/butoralk/kronosmortus.com/html/wp-content/plugins/wp-snap/wp-snap.php on line 398
Anyone found the cause of this? Cheers!
This isn’t a bug. Your installation of WordPress has no posts, so the plugin fails. Add some content to your site. Also, if you do encounter an actual bug, please provide steps to reproduce it or your feedback is worthless. Thanks!
Hey, thanks for the quick reply!!
Actually as you can see http://www.kronosmortus.com has a lots of posts in several categories.
It works without firstload=recent, but if I use firstload=recent I receive this error.
I put the code into the index.php after the queries.
Thanks
I love this plugin – exactly what I was looking for! =)
I might have found a “bug” or an unwanted effect: I´ve added a three characters to the Local Alphabet field in the admin – ÅÄÖ. But when I click on these characters on the site, a ‘Page not found’ message shows.
It seems like an easy thing to fix but i´m not a PHP ninja. Does anyone have an fix for this? It´d be nice if I could add something to the functions.php file so that the code survives an upgrade.
I´m using WordPress 3.2 – which seems to be working fine by the way.
Thanks for the heads up. I might actually have some time to work on a new update this summer. I’ll check this out when I do.
Hi,
I cannot get this to work with the latest version of WP. Any ideas?
Works for me.
Hello Nathan:
Thanks for a great plugin, I’ve been using it for a little while now and I really like it.
If you have a moment, though, I would like to ask a question about the error message described by Tom in a previous comment. (I’ll do my best to provide the most useful information possible… without going overboard.)
I’m using WP-SNAP largely as instructed, I think. In my case, I’m using it to display posts only from category number “30″. I do this by using a “category-30.php” file in which I have the following relevant code:
It works fine as shown above — it displays by default on the entry page all entries for the letter ‘A’ — but I wanted to try instead to get the five most recent entries listed on the entry page, so I set WP-SNAP’s setting accordingly and changed the code in my category-30 file, first to this:
…and then to this:
…and just for the hell of it, this (I have no child cat):
I also tried using just a category.php instead of category-30.php, but the problem persisted.
Curiously, if I use a non-existent category number, for instance:
… the entry page displays displays the ten most recent entries (ten being the number of posts set to be displayed in my WordPress sitewide settings). This isn’t so bad, but the only drawback is that it displays “No posts found matching criteria” before listing the ten most recent posts.
This is hardly an urgent issue, of course, since my installation is quite workable as is, but if you have any suggestions for getting the built-in recent posts function to work, I’d be happy to hear them.
Thanks kindly!
Hedley
So much for using the code paster… if you care to see it, here’s a link to a pdf (if it will let me paste a link):
http://www.dooneyscafe.com/stuff/hedleycomment.pdf
At any rate, one addendum: I later noticed that the ‘non-existent category number’ trick didn’t really work – the WP-SNAP alphabet had vanished, making the workaround sort of useless.
Back to tinkering…