I am trying to set the excerpt length for WooCommerce products but the following code does not work as expected:
<?php
function custom_excerpt_length($length) {
global $post;
if ($post->post_type == 'post')
return 10;
else if ($post->post_type == 'product')
return 10;
else if ($post->post_type == 'product_variation')
return 10;
}
add_filter('excerpt_length', 'custom_excerpt_length');
?>