• Resolved kreen

    (@kreen)


    Dear guys.

    I have a problem after update to wordpress 4.3 that never happen before.

    The problem is on my homepage all of article display full of content instead of post excerpts which I chose from Theme Options in the dashboard.

    And the function of theme options > blog> Excerpt Length seems not working any more.

    I’ve try to modify code below from function.php followed this article

    /*  Excerpt ending
    /* ------------------------------------ */
    if ( ! function_exists( 'alx_excerpt_more' ) ) {
    
    	function alx_excerpt_more( $more ) {
    		return '...';
    	}
    
    }
    add_filter( 'excerpt_more', 'alx_excerpt_more' );
    
    /*  Excerpt length
    /* ------------------------------------ */
    if ( ! function_exists( 'alx_excerpt_length' ) ) {
    
    	function alx_excerpt_length( $length ) {
    		return ot_get_option('excerpt-length',$length);
    	}
    
    }
    add_filter( 'excerpt_length', 'alx_excerpt_length', 999 );

    But look likes work in vain. Even I deleted it, the result is still the same.

    Could you guys give a hand? Any suggestion would be grateful. Thanks for your attention.

Viewing 15 replies - 1 through 15 (of 18 total)
  • Hi kreen. Welcome to the Hueman forum. Upgrading to WP 4.3 should not have made any changes to the theme files. By default the theme displays (1) the full manually-entered excerpt if it exists, or (2) the excerpt derived from the post content, up to the number of words set in Theme Options > Blog > Excerpt Length. You shouldn’t need to modify any theme functions. Can you post a link to your site so we can take a look? Thanks.

    Thread Starter kreen

    (@kreen)

    Hi bdbrown, thanks for your kind reply. Here is my site:https://kreen.org/

    After update to wordpress 4.3, It’s become like that, then I try to modify it……Unfortunately, looks like my lack of coding ability. Btw, I put original function.php with this theme back.

    Thank you for considering my request.

    I don’t see anything obvious that would cause the change. Have you modified any theme files related to posts? Or do you have any plugins that are related to displaying or styling posts?

    Thread Starter kreen

    (@kreen)

    Yes, but I restore it by delete entire hueman folder from ftp, then upload brandnew zip from github again.

    All plugin I used are recommended plugins by theme, and:

    1.All In One SEO Pack
    2.Cyclone Slider 2
    3.Disqus Conditional Load
    4.Jetpack % Akismet
    5.UpdraftPlus – Backup/Restore
    6.W3 Total Cache

    I’ve try deactivate all plugins, no effect on excerpts length. But change theme does. Problem is I love this theme more than other theme ??

    What happens if you download and install the zip file from the theme web site? Any change?

    Thread Starter kreen

    (@kreen)

    Thanks for Your advice.
    I got same outcome,But……

    After install the theme again and post a test article. I think the problem could depend on language. Article in English would follow the excerpts length which adjusted from theme option, article in tradition chinese(zh-tw, Taiwan) won’t.

    It’s wired.

    I found this post which sounded relevant.

    Here is the Codex reference on the wp_trim_words function.

    Add this to your child theme functions.php file and see how it works; change the number to fit your requirements:

    /* trim excerpt to 55 words */
    add_filter('the_excerpt', 'my_excerpt_filter');
    function my_excerpt_filter($excerpt) {
        echo wp_trim_words( $excerpt , '55', '...' );
    }
    Thread Starter kreen

    (@kreen)

    I got same result.

    Consult the “test post” which post in English, excerpts length still decide by the theme options.

    And I observe that excerpts length in Chinese may become much more than theme options set. Number of words increased is incorrect proportion. I still not figure out why course such outcomes.

    Thread Starter kreen

    (@kreen)

    I try to use plugins to solve excerpts length problem. Plugins listed below are what I try and its effect on my website.

    1.Advanced Excerpt Options:Characters mode works, but words mode won’t. Beside that all features works flawless.

    2.Easy Custom Auto Excerpt:Both characters mode and paragraph mode may change excerpts length, but characters mode would counting not only content but also title characters. And “read more” can’t turn to link.

    3.”Rich Text Excerpts” and “WP CN Excerpt” both are not effect on my site.

    4.WP-UTF8-Excerpt works great. There are not much options, only give basic function likes: a.length of excerpts on homepage, archive. b.Allow HTML tags, c.Display the “read more” link as what I set.

    After testing five excerpts plugins, I think the major excerpts length problem on this theme in WordPress 4.3 cause by “word” distinguish in multibyte language such as Chinese and Japanese.

    Although I can’t use theme options to adjust excerpts length any more, but solved the problem by plugins is an acceptable way for me.

    Particularly grateful to bdbrown for your enthusiasm and timely help.

    You’re welcome. Glad I could help. And thanks for the info on the various plugin options; hopefully that will be helpful for someone else. If you don’t need any further assistance with this topic please mark it as Resolved. Thanks.

    Thread Starter kreen

    (@kreen)

    I appreciate your help. Hope this topic would help someone who uses this theme and blogging in Chinese, Japanese.

    Any advice or suggestion on how to handle multibyte language still are welcome.

    Same problem here.

    WP 4.3 seemed to have changed trunctation from characters to words.

    I have changed my php from 210 (previously characters) to 30 (currently words).

    I’m glad someone else has brought this up, I thought I was losing my mind. The excerpts on my wordpress websites have gotten RIDICULOUSLY long after upgrading to 4.3.

    Ysan, how can I alter my php like you did?

    Hello MarineKingAizen,

    I don’t know about your theme, but I have changed some php code in my theme file. Search for something that looks like :

    <?php truncate_post(30,false) ?>

    At least, this is how it looks like in my theme.

    Previously the number was 210 (characters). I have changed this to 30. WP 4.3 seems to have changed this into words.

    Hope this helps.

    All the best,

    Yves

    Hi, Kreen

    I have had the same problem before and I’m afraid at this point there’s no perfect solution especially when having a bilingual type of website where different character types are mixed. I could create one but It would take a lot of time.

    Here is a simple filter to fix this problem. The First thing is to detect if the post excerpt is in fact written in Chinese and if so we want to use a couple of multi-byte string function provided by PHP. Keep in mind the filter will not effect English posts.

    The first function is mb_strlen and we will use this to check if the excerpt exceeds our limit and if so we would like to add a decorator to the end of the string. The second function is mb_substr and it will limit the actual string to the limit we defined in the top of the function.

    Below is an example filter, feel free to give it a try. Keep in mind your theme needs to use the get_the_excerpt() method.

    /**
     * Filters the excerpt to limit Chinese strings properly.
     *
     * @return string The new limited excerpt
     */
    function filter_chinese_excerpt($excerpt){
    
        // Chinese excerpt limit. Set your limit here!
        $limit = 130;
    
        // Ending decoration. ([...])
        $decoration = '[…]';
    
        // If Chinese.
        if(preg_match("/\p{Han}+/u", $excerpt)){
    
            // If longer then limit add decoration to end of string.
            // Also returns the string
            if(mb_strlen($excerpt, 'UTF-8') >= $limit){
                 return mb_substr($excerpt, 0, $limit, 'UTF-8') . $decoration;
             }else{
                 return mb_substr($excerpt, 0, $limit, 'UTF-8');
             }
        }
        return $excerpt;
    }
    add_filter('get_the_excerpt', 'filter_chinese_excerpt');

    Thanks, Vernon

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Excerpts become full of content’ is closed to new replies.