title

Change excerpt length depending of the category

 

Change excerpt length depending of the category

11 Mai 2013, Posted by antoine in

Ever wished to modify the excerpt length based on which category you are on? Here comes the code which grants your wish. Simply paste the code into your functions.php file, and don’t forget to change the category ID on line 3!

add_filter('excerpt_length', 'my_excerpt_length');
function my_excerpt_length($length) {
    if(in_category(14)) {
        return 13;
    } else {
    return 60;
    }
}