New Landing How can we help? Atelier Excerpt length setting is not working with Chinese

Viewing 15 posts - 1 through 15 (of 15 total)
  • Posted in: Atelier
  • #269271
    ngaiwinghong
    Member
    Post count: 28

    Dear Support team,

    I was playing around with the excerpt length option in the “recent post” module, and found it is not working. Finally I find out the problem is that it only count the English words but ignore the Chinese characters. Is there any chance I can fix it? (Please see the attached screencapture.

    Thanks!

    Hong

    Attachments:
    You must be logged in to view attached files.
    #269958
    ngaiwinghong
    Member
    Post count: 28

    sorry, but I have been waiting for 2 days, is there anyone can help me please? Thanks!

    #269975
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    Apologize for the delay. Will have to forward this situation to our head developer because it seems it’s a general issue in WordPress.

    -Rui

    #270123
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Thanks for the heads up, we will resolve with the next update. Reference: http://wptutorial.narrativecard.com/wordpress-excerpt-problem-chinese/

    – Ed

    #317841
    greattai
    Member
    Post count: 5

    Hi!
    May I know the status of this issue?
    I got the same problem…
    I search around and found this plug-in to solve this issue but unfortunately its not working with the theme,
    please let me know, thanks!!

    WP CN Excerpt

    #317872
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Will forward it to Ed so he can reply about it.
    -Rui

    #318363
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Hi @greattai

    That plugin would not work with our theme. Do you have the latest theme + plugin updates?

    – Ed

    #318376
    greattai
    Member
    Post count: 5

    Hi Ed,
    Yes, I am using the latest theme and plug-in.
    Btw..the problem I want to fix is “chinese excerpt length”… its ok if you have other suggestion.
    thanks!

    #318469
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Please try this version of the theme – http://swiftideas.d.pr/8V4k/Ab6G3eWF

    That should sort it for you!

    – Ed

    #318521
    greattai
    Member
    Post count: 5

    Hi Ed,
    Thanks for your reply, but the problem seems still exist..
    May I know what do you update on the new zip ?

    As I know.. the usual “word length” is count by space for english,
    and chinese “word” without space.

    Is it possible to just give me a code to use on the child theme to count by words instead of space ?

    And I also suggest to add a option on the “Excerpt Length” by “space(default)” and “character” later on.
    thanks!

    *attached with the screen cap I use “15” as the Excerpt Length on your zip.

    Attachments:
    You must be logged in to view attached files.
    #318858
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Hi there,

    You can try changing these 3 functions – https://www.dropbox.com/s/owp0xr30dri4p8j/Screenshot%202017-03-28%2016.44.01.png?dl=0

    Let us know if any changes work for you, and we can integrate the “function_exists” check so they can be overridden in a child theme.

    – Ed

    #322374
    greattai
    Member
    Post count: 5

    Hi, sorry for so long.. what I did on these 3 functions on swift-framework/core/sf-formatting.php and its working fine for me now (to count characters instead of words):

    function sf_excerpt( $limit ) {
    global $post;
    $excerpt = “”;
    $custom_excerpt = sf_get_post_meta( $post->ID, ‘sf_custom_excerpt’, true );

    if ( $custom_excerpt != “” ) {
    //edited by titus
    //$excerpt = wp_trim_words( $custom_excerpt, $limit );
    $excerpt = wp_html_excerpt( $custom_excerpt, $limit, ‘…’);
    } else {
    //edited by titus
    //$excerpt = wp_trim_words( get_the_excerpt(), $limit );
    $excerpt = wp_html_excerpt( get_the_excerpt(), $limit, ‘…’);
    }
    $excerpt = preg_replace( ‘\[[^\]]*\]‘, ”, $excerpt );

    return ‘<p>’ . $excerpt . ‘</p>’;
    }

    function sf_content( $limit ) {
    $content = wp_trim_words( get_the_content(), $limit );
    $content = preg_replace( ‘/\[.+\]/’, ”, $content );
    $content = apply_filters( ‘the_content’, $content );
    $content = str_replace( ‘]]>’, ‘]]>’, $content );

    return $content;
    }

    function sf_custom_excerpt( $custom_content, $limit ) {
    $locale = get_locale();
    $content = ”;
    /* edited by titus
    if ( $locale == ‘zh_CN’ || $locale == ‘zh_SG’ || $locale == ‘zh_HK’ || $locale == ‘zh_TW’ ) {
    $content = wp_trim_words( $custom_content, $limit );
    } else {
    $content = $custom_content; // This is needed to keep formatting
    }*/
    $content = wp_html_excerpt( $custom_content, $limit, ‘…’);
    $content = preg_replace( ‘/\[.+\]/’, ”, $content );
    $content = apply_filters( ‘the_content’, $content );
    $content = str_replace( ‘]]>’, ‘]]>’, $content );

    return $content;
    }

    #322393
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Great. Thanks for sharing your code.

    -Rui

    #323293
    greattai
    Member
    Post count: 5

    Hi Rui,

    How can I put this on the child theme?
    Its overwrited after theme update. please advise, thanks!

    #323375
    David Martin – Support
    Moderator
    Post count: 20834

    Hi,

    When the next update is released you will be able to overwrite this via a child theme. Currently, this is not possible.

    I have submitted a patch to enable this for the next release.

    Thanks.

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register