Change Excerpt Length of WordPress Theme

In blog section, most of the WordPress themes display a part of the content of the post. By default the the_exerpt() function displays 20 words of the content. To decrease or increase this length, add below code to the functions.php file of your theme.

if (!function_exists('hs_alter_excerpt')) :
     * Filter to change excerpt length size
    function hs_alter_excerpt($length)
        if (is_admin()) {
            return $length;

        return 50;
    add_filter('excerpt_length', 'hs_alter_excerpt');

In code as you can see it will return 50 that is 50 words of the content.

Shopping Cart