WP-SNAP! WordPress Plugin

Permalink  |  Comments [353]

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:

screenshot

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!

  1. 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.
  2. Activate the Plugin from the WordPress Administration Plugins tab.
  3. 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(); } ?>
  4. Copy the CSS example below and paste it into your WordPress Theme stylesheet (you can style it better later).
  5. Upload the files and refresh the category page on your WordPress blog to see it in action.
  6. 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'); } ?>
  7. 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 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

Technorati TagsTags: , ,


Comments

Pages: « 1 2 [3] 4 518 » Show All

  • 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.

  • [...] WP-SNAP! WordPress Plugin Es el dia de los plugins novedosos. Este plugin permite hacer algo que hace tiempo andaba buscando, que es navegar alfabeticamente por los posts. Chori, no? (tags: wordpress plugin plugins navigation alphabetical alfabeto abc Browse) [...]

  • 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.

  • Sorry, didn’t realise the form wouldn’t take the code. In the previous comment, I meant I am using $query_string .’orderby=title&order=asc’ in query_posts() to generate the alphabetical list of posts for my glossary.

    Hope this makes sense?

  • Well, I did it. What I thought would be a quick addition turned into me re-arranging half the plugin. Presenting WP-SNAP! v0.5. One can now filter words from the alphbetization (I think I just made that word up) process by inputting them into a box on the admin page. Thanks Ki and C for the great input!

    Indi — I don’t think what you’re looking for should be too difficult, but you’re going to have to do some footwork. I pull all the post_titles using a simple MySQL query. Looking at Gengo’s code, it looks like it creates a MySQL table to track the post translations. It shouldn’t be too difficult to hack the query in WP-SNAP! to only pull one set of translations based on the currently selected language. However, I don’t have the time to figure out how to do this. I suggest that you ask the creator of the Gengo plugin. Here’s the query I use:

    $wp_snap_posttitles = $wpdb->get_results("SELECT `post_title`, `post_content`, `post_excerpt`, `ID`, `post_password` FROM $wpdb->posts, $wpdb->post2cat WHERE `post_id` = `ID` AND `post_status` = 'publish' AND `category_id` = '" . $wp_snap_cat . "'");

    If he can help you out with the query, I can tell you how to put it back in. Good luck!

  • Awesome, thanks Nate! On the QA front, it appears that the ignore array must be lowercase… at least, when I enter “A|An|The” as my ignore terms, all of my A entries disappear. Not a problem, however, when it’s lowercase, so I’ll be sticking to that :)

  • C — Good catch! I’ve reworked some of the code and I think I fixed the problem. Please let me know if you notice any more strange behavior.

    By the way, with regards to your previous comment about being able to call the menu without listing the posts. I can do this. I don’t think it would be too hard. It’s probably going to be a couple of weeks before I can get to it though.

  • Is there a version of ths plugin for wordpress mingus 1.2 version?

  • Thanks for the plugin. I have been testing it and wondered if there could be a function added that would not ‘page’ the sections but instead just create an anchor that would take you down to the correct place on the page?

    Also, is there a way to choose if I want:
    A B C D ….
    or
    A-D E-G ….
    by using a specific php call instead of from the admin menu? Sometimes I might want to use different formats within the same blog for different categories. Some have many many links, others have just many :)

    Thanks in Advance, WP-Snap’s features are something I have been looking for since I moved from snip-snap as a Content Manager to WordPress.

  • Pages: « 1 2 [3] 4 518 » Show All

    Leave a Reply

    Allowed markup: a blockquote br code em pre strong ul ol li

Download The Latest Release

WP-SNAP! v0.8.5 (zip archive)

View The Code

WP-SNAP! v0.8.5 (phps)

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

  1. 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.

  2. 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.

  3. 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.