Title: Exclude non alphanumeric characters &#8211; again
Last modified: March 10, 2020

---

# Exclude non alphanumeric characters – again

 *  [ceol](https://wordpress.org/support/users/ceol/)
 * (@ceol)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/exclude-non-alphanumeric-characters-again/)
 * Hi.
    Trying to implement solution from [here](https://wordpress.org/support/topic/exclude-non-alphanumeric-characters/):
 *     ```
       <?php
       add_filter( 'a_z_listing_item_index_letter', 'ignore_quotes_in_a_z' 10, 3 );
       function ignore_quotes_in_a_z( $indices, $item, $item_type ) {
           $title = get_the_title( $item );
           for ( $i = 0; $i < strlen( $title ); $i++ ) {
               $letter = substr( $title, $i, 1 );
               switch ( $letter ) {
                   // add all the characters you want to ignore here - switch falls-through
                   // so if any one of these are matched we hit the break; and continue
                   // to the next letter in the title.
                   case '"':
                   case '\'':
                   case '(':
                   case '[':
                       break;
                   // if none of the above match then we use the character as the index
                   default:
                       return [ $letter ];
               }
           }
   
           // This is here to handle the case of the above code not giving an index
           return $indices;
       }
       ```
   
 * by inserting into child theme functions.php but getting errors.
    Any advice for
   a tech knuckle-head most appreciated. Many thanks

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Thread Starter [ceol](https://wordpress.org/support/users/ceol/)
 * (@ceol)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/exclude-non-alphanumeric-characters-again/#post-12531760)
 * …inserted comma in first line before 10 like so:
    `add_filter( 'a_z_listing_item_index_letter','
   ignore_quotes_in_a_z', 10, 3 );` Saves ok now but doesn’t appear have any effect
   on the listing. Any ideas much appreciated, Thanks
    -  This reply was modified 6 years, 2 months ago by [ceol](https://wordpress.org/support/users/ceol/).
 *  Thread Starter [ceol](https://wordpress.org/support/users/ceol/)
 * (@ceol)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/exclude-non-alphanumeric-characters-again/#post-12532442)
 * Have several instances (one per category) in a page using shortcode like: `[a-
   z-listing display="posts" post-type="post" taxonomy="category" terms="miscellaneous"
   grouping="26"` if that’s relevant. thanks
    -  This reply was modified 6 years, 2 months ago by [ceol](https://wordpress.org/support/users/ceol/).
    -  This reply was modified 6 years, 2 months ago by [ceol](https://wordpress.org/support/users/ceol/).
 *  Plugin Author [Dani Llewellyn](https://wordpress.org/support/users/diddledani/)
 * (@diddledani)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/exclude-non-alphanumeric-characters-again/#post-12532662)
 * Hi,
 * Can you post an example of a title that is failing to ignore a special character
   with the above code?
 * Make sure you copy it from the title field in your wp-admin editor and paste 
   it inside a “code” block here, so that any special characters are not mangled
   by any intermediate processes. To paste into a code block click the “code” item
   in the toolbar above the reply text box and then paste the title between the `\``
   characters.
 *  Thread Starter [ceol](https://wordpress.org/support/users/ceol/)
 * (@ceol)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/exclude-non-alphanumeric-characters-again/#post-12532827)
 * Hi.
    `'a test apostrophe index title'` `"a test quote index title"` Thanks for
   replying.
 *  Plugin Author [Dani Llewellyn](https://wordpress.org/support/users/diddledani/)
 * (@diddledani)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/exclude-non-alphanumeric-characters-again/#post-12532953)
 * Oh, I think I see the issue.
 * You’ve set `grouping=26` which will group all the posts into a single bucket.
   This means that the only ordering will be via a PHP comparator using `strcmp`.
   The above code will only affect which group a particular title is listed within,
   not its order inside that group.
    -  This reply was modified 6 years, 2 months ago by [Dani Llewellyn](https://wordpress.org/support/users/diddledani/).
 *  Thread Starter [ceol](https://wordpress.org/support/users/ceol/)
 * (@ceol)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/exclude-non-alphanumeric-characters-again/#post-12533075)
 * Hi.
    I removed the grouping just to see but no change; very strange. Thanks
 *  Thread Starter [ceol](https://wordpress.org/support/users/ceol/)
 * (@ceol)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/exclude-non-alphanumeric-characters-again/#post-12540111)
 * Hi.
    I’ve discovered that part of the issue seems to be with _certain_ characters
   only: seems to be working with `(` and `[`, but not with `“` or `\` How might
   I get it working for double quotes and apostrophe? Thanks
 *  Plugin Author [Dani Llewellyn](https://wordpress.org/support/users/diddledani/)
 * (@diddledani)
 * [6 years ago](https://wordpress.org/support/topic/exclude-non-alphanumeric-characters-again/#post-12686277)
 * I suspect the issue with double-quotes or apostrophe might be a difference between`"`
   and `＂` or `'` and `＇`.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Exclude non alphanumeric characters – again’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/a-z-listing_d8edfd.svg)
 * [A-Z Listing](https://wordpress.org/plugins/a-z-listing/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/a-z-listing/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/a-z-listing/)
 * [Active Topics](https://wordpress.org/support/plugin/a-z-listing/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/a-z-listing/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/a-z-listing/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [Dani Llewellyn](https://wordpress.org/support/users/diddledani/)
 * Last activity: [6 years ago](https://wordpress.org/support/topic/exclude-non-alphanumeric-characters-again/#post-12686277)
 * Status: not resolved