I have multiple layouts which are being used in the theme. Now, I require different excerpt length for every layout. I tried using the ‘excerpt_length’ filter in functions.php but it affects the excerpt site-wide and not a particular layout.
Since the layouts are being controlled using customizer, get_theme_mod comes into play but it can only be used to influence a particular page – not a particular layout ( e.g. if get_theme_mod is used to change excerpt length of blog page for a particular layout, it would be the same length if the layout is changed from the customizer ).
Basically, I want select to perform a function similar to is_page_template() but for post layouts. Hope I am clear enough.
Read more here:: How to select a particular post layout across theme