仅更改主页摘录的单词数

Impossible to use different excerpt settings for the home page ...! I tried a conditional function in functions.php with : is_home, is_front_page, both, is_page_template( 'home.php')… The number of words is changed for the other pages, for categories, but never for the home page :

function custom_post_excerpt($length) {     
    if(is_category()){ 
        return 10;
    }elseif(is_page_template( 'home.php' )){ 
        return 0;
    }else{ 
        return 81;
    }
}
add_filter('excerpt_length', 'custom_post_excerpt');

I also tried to modify the excerpt in the page itself with:

<?php if (!empty($post->post_excerpt)) {the_excerpt();} ?>

Without any success either…

I have a custom excerpt containing a YouTube iframe tag for each CPT that appears on the 'home.php' page, but I would like nothing to show in this excerpt if the custom excerpt field in the back office is not filled (otherwise an automatic text extract appears in place of the video).

Would someone have an idea about what's wrong ?…


I finally found a solution to target post types, as posts types on my home page are 'custom_post_type' and not 'post' :

function post_excerpt_length($length) {
global $post;
if ($post->post_type == 'post') {
return 81; 
} else {
return ''; }
}