Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • There’s a min-height property active on your themes images. If you know how to edit your theme’s main CSS file then simply just override the active property with the following.

    .vw-post-box-thumbnail img {
        min-height: auto !important;
        height: auto !important;
    }

    It also seems that you are using a plugin that speeds up your theme. I would suggest that you disable it if the above CSS doesn’t work as it combines your CSS files into one large minified file. This might affect the Cascading effect of CSS (order of inclusion).

    Thanks

    Vernon Grant

    (@vernonrant)

    Hi David.

    I placed your code into a single PHP file. After that I included the file into the loop of the following files: index.php, archive.php and search.php I also places a unique echo statement in each condition and got back the expected results. Your code seems to work just fine for me.

    Thanks, Vernon

    Vernon Grant

    (@vernonrant)

    Hi David,

    I think I might have miss read your question lol. So your using this peace of code as an include file to run across your themes files, archive.php, search.php… Let me take a look and get back to you.

    Thanks, Vernon

    Vernon Grant

    (@vernonrant)

    Cool, I’m glad I could help.

    Vernon Grant

    (@vernonrant)

    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 5 replies - 1 through 5 (of 5 total)