Changing the_excerpt length not working with Sage

Hi,

I’m trying to change the excerpt length globally for the site I’m currently working on. I’m adding the code provided by wordpress to my extras.php file, but when I’m viewing the updated changes with gulp watch the only thing I see is “… Continued”.

function custom_excerpt_length( $length ) {
	return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );`

source: https://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt_length

This is first change I’ve made to a php file in sage other than messing with .scss files.

I’m wondering if it’s something the the sage theme is interfering with? Any help would be appreciated.

Are you developing with WP_DEBUG disabled? You should be seeing a PHP error — you are not calling your custom function properly.

Read https://roots.io/upping-php-requirements-in-your-wordpress-themes-and-plugins/

This has also been brought up several times on this forum. lib/extras.php is namespaced and you are trying to call a function without supplying the namespace.

Look at how the other functions are being called with __NAMESPACE__.

3 Likes

Overlooked that when I was setting up this new environment. I had WP_DEBUG disabled.

Thanks, I fixed __NAMESPACE__ and everything looks good.

1 Like