[Resolved] Blog setting "Excerpt word count" doesn't work on other language.

Home Forums Support Blog setting "Excerpt word count" doesn't work on other language.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1309816
    Kin

    Hi all,
    I just brought your premium plan a week ago.
    Most of the things are good, I am satisfy about that.

    However, there is one thing I am so confuse , which is the setting under Customizing > Layout > Blog > Excerpt word count, the default value of “Excerpt word count” should be 20.
    There looks nice on your demo page, however, when I already wrote the article with Transitional Chinese version, it seems doesn’t count the words correctly. It looks terribly long chinese text display even if I set the “Excerpt word count” to 5-10.

    Would you please help or provide some solution can solve this problem?
    I am appreciated about this.

    #1309873
    David
    Staff
    Customer Support
    #1319051
    Kin

    Hi, Thank you for your information provided,
    I followed your link and fixed the Excerpt word count problem.
    However,it seems that another issue existed, the problem is the “read more” button only disappear on chinese language article,the default english article remain normal, please check this
    Image

    I am look forward to hearing from your.
    Thanks a lot.

    #1319052
    Kin
    #1319080
    David
    Staff
    Customer Support

    Try this function:

    function dez_filter_chinese_excerpt( $output ) {
        global $post;
        //check if its chinese character input
        $chinese_output = preg_match_all("/\p{Han}+/u", $post->post_content, $matches);
        if($chinese_output) {
            $output = sprintf( '%1$s <p class="read-more-button-container"><a class="button" href="%2$s">%3$s</a></p>',
                mb_substr( $output, 0, 50 ) . '...',
                get_permalink(),
                __( 'Read more', 'generatepress' )
            );
        }
        return $output;
    }
    add_filter( 'get_the_excerpt', 'dez_filter_chinese_excerpt' );
    #1319337
    Kin

    Thank you for your help,
    The problem has been solved.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.