AZIndex 0.5.3 Released

AZIndex LogoAZIndex version 0.5.3 has just be released.  It’s just another interim version as I am gearing up for my summer vacation, mainly to fix a bug where the sorting of the headings was case-sensitive.  I’m not sure how that one escaped detection for so long!

I also took the opportunity to add a filter to the plugin — ‘azindex_heading’ — which, if set, will be called for every heading before the index is sorted.  This allows users to write a filter function that can modify the heading in ways that can’t currently be done using the AZIndex plugin — for example, if you want to strip words like “A”, “An” and “The” from the front of the heading then you can write a simple filter to do that.

Below is an example of such a filter.  It will remove “The”, “An” and “A” (of various cases) and put them at the end of the heading instead — e.g. “The Great Escape” will be transformed to “Great Escape, The”.  Useful for certain types of indexing:

add_filter('azindex_heading', 'my_filter_heading');                  

function my_filter_heading($heading) {
   if (preg_match('/
^(THE |The |the |AN |An |an |A |a )/', $heading)) {
       $split = explode(' ', $heading, 2);
       $heading = $split[1].
', '.$split[0];
   return $heading;

Note that this is just an example and there may be a more correct way to do the same thing, but it works as advertised.  You can add your filter function to the functions.php file in your current theme.  Remember to clear the index cache (from the AZIndexes admin page) once you’ve added the filter so that the altered headings will be sorted in the correct order.

If anyone comes up with a useful filter function of their own, please feel free to post it here.

4 thoughts on “AZIndex 0.5.3 Released

  1. Jeff

    Mike, Thanks a lot!! This really helps.

    BTW, slight problem …typo I assume … in the preg_match expression…the carot and opening parens ^( need to be inside the opening delimiting slash. Otherwise, it works great. Once our site is live, I’ll let you know the URL.

  2. English Mike Post author

    Hi Jeff, oops — I initially forgot the caret altogether so I pasted it in afterward, in the wrong place. ‘Tis corrected. Thanks. Look forward to seeing the site when it’s done.

  3. pinzaru

    I just updated to WordPress 2.6, everything works fine except de AZIndex 0.53 wich was released yesterday… Every time edit a post i got lots of error messages, WordPress saying was expecting bla bla…… (i deactivated and deleted azdindex so i can’t tell right now the exact error messagers) So… when a 0.5.4 version? 🙂

    Thank you.


Leave a Reply

Your email address will not be published. Required fields are marked *