• Resolved sipoax

    (@sipoax)


    Hi,

    I read pretty much everything written here. I couldn’t find a solution to my problem.

    Some of the titles of my articles start with diacritics (??, ??, ??).

    I put this code in the article where I want to display the index: [az-listing display = “posts” alphabet = “Aáà?aáà?, ??, ?a, Bb, C?c?, Dd, Eéè?êeéè?ê, Ff, Gg, Hh, Iíì?iíì?, ??, Jj , KK, LL, MM, NN, oooooooooo, PP, QQ, RR, Ss, ??, TT, ??, Uúùü?uúùü?, Vv, Ww, Xx, Yy, Zz “]

    At the top where the alphabet is displayed the diacritics (??, ??, ??) appear, but below where the links are displayed the articles starting with diacritics are displayed at #.

    I mention that I checked and mbstring is active.

    Isn’t there a solution to introduce some filter in function.php so as to force articles starting with diacritics (??, ??, ??) to be displayed in (Ss, Tt, Ii)?

    PS: I also tried with alphabet = “Aáà??aáà?a, Bb, Cc, Dd, Eéè?êeéè?ê, Ff, Gg, Hh, Iíì??iíì??, Jj, Kk, Ll, Mm, Nn, Oóò??oóò??, Pp, Qq, Tr, S, T r , Vv, Ww, Xx, Yy, Zz “the result is the same, indexing articles with diacritics at #

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Dani Llewellyn

    (@diddledani)

    Hi,

    Please copy and paste the exact shortcode from your site. Make sure when you paste the shortcode into the reply box that you use the editor’s “code” feature to correctly mark your input as code. This will ensure that the editor does not mangle the characters you input, such as changing " to , which it has done in your original post.

    Thread Starter sipoax

    (@sipoax)

    I tried both codes below:

    [a-z-listing display="posts" alphabet="Aáà?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" post-type="page"]

    [a-z-listing display="posts" alphabet="Aáà???aáà?a?,Bb,Cc,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" post-type="page"]

    The first code to differentiate ?? from Ss, ?? from Tt, ?? from Aa, ?? from Aa, ?? from Ii.

    The second to try to include ?? in Ss, ?? in Tt, ?? in Aa, ?a in Aa, ?? in Ii

    The result is the same: articles are entered at #

    Plugin Author Dani Llewellyn

    (@diddledani)

    Both of those variants look like they should work. Is it possible that the added letters with diacritics are a different unicode code-point to the first letter of your pages? To be sure you could try copying the first letter of an affected page’s title from the edit-page screen and then paste that into the alphabet. If that still fails, I’m unsure what the problem is…

    Thread Starter sipoax

    (@sipoax)

    ignore this message, see the following message!

    I think I found the problem, but I don’t know how to fix it.

    I use the OceanWP theme and I use the child theme. With the child theme enabled, the problem above appears. If I only activate OceanWP (without the child theme) the AZ Listing theme it works perfectly.


    Maybe you have any suggestions?

    • This reply was modified 4 years, 11 months ago by sipoax.
    • This reply was modified 4 years, 11 months ago by sipoax.
    Thread Starter sipoax

    (@sipoax)

    Hmmm It’s my fault. Your plugin works perfectly.

    I checked function.php and found that I had added a few lines of code. Looks like something is not ok with what I added.

    add_filter( 'a_z_listing_item_index_letter', 'my_a_z_index_filter', 10, 3 );
    
    function my_a_z_index_filter( $index_letters, $item, $item_type ) {
        // make sure we're filtering the right post type
        if ( 'page' === get_post_type( $item ) ) {
            // pull the title and get the first letter of the second word
            $full_name = explode( ' / ', $item->post_title );
    
            // the last word is in the last element of $title_parts so check it is there
            $last_name = array_pop( $full_name );
    
            // ensure we actually found a last name
            if ( $last_name )  {
                // cut the first letter out for our index
                $index = substr( $last_name, 0, 1 );
    
                // set up a new empty array overwriting the old indices
                $index_letters = array( $index );
            }
        }
    
        // return the indices item's indices
        return $index_letters;
    }

    Can you please help me?

    I’m using this code in another index on the site. I need to remove the first two words in the title so that the sorting is done by the third word. Something like this:

    XXX YYY A
    XXX YYY B
    XXX YYY C

    I do not want all articles to appear in X, but depending on A, B, C I want titles to appear in letter A, B, C.

    The above code works for this need but it seems that it disturbs the diacritics in the title.

    Plugin Author Dani Llewellyn

    (@diddledani)

    You could try replacing substr() with mb_substr(), which requires that your PHP installation has the multibyte string (mbstring) extension enabled. You did indicate that it is enabled, but I just wanted to double check that..

    Thread Starter sipoax

    (@sipoax)

    Thank you! It works like a charm!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Again about UTF-8 and the display at #’ is closed to new replies.