Hi,
Each item in the list is passed through a filter called a_z_listing_item_index_letter which allows you to change the detected index letter. For this example you can do something like below:
<?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;
}
Hi there,
Thanks for the answer.
It works, but not as expected, all accented characters (ÁáÉéÍíÓóÖöŐőÚúÜüŰű) went under #
I added some characters to the alphabet with the following code, it worked fine until now.
add_filter( 'a-z-listing-alphabet', 'add_hun');
function add_hun( $alphabet ) {
return 'AÁÀÄÂaáàäâ,Bb,CÇcç,Dd,EÉÈËÊeéèëê,Ff,Gg,Hh,IÍÌÏÎiíìïî,Jj,Kk,Ll,Mm,Nn,OÓÒÖŐÔoóòöôő,Pp,Qq,Rr,Ssß,Tt,UÚÙÜŰÛuúùüűû,Vv,Ww,Xx,Yy,Zz';
}
Thanks
with mb_substr() instead of substr() works great, thanks!