WordPress WordPress Theme Development Adding a Blog to a WordPress Theme Coding the Blog Homepage

David Wall
David Wall
11,088 Points

function wpt_excerpt_length

I'm not sure i understand how this works.

function wpt_excerpt_length($length) { return 16; }

add_filter('excerpt_length', 'wpt_excerpt_length', 999);

We've created a function that will call on $length and change it to 16. So $length was set by WP by default specifically to be excerpt length at a global level?. So if i echo out the var $length anywhere in my WP code it will give me the length of my excerpts?! It seems like a fairly generic var label. If so, after excerpt_length is requested the function wpt_excerpt_length is run and $length now = 16 globally? I mustn't be understanding this correctly.

David Wall
David Wall
11,088 Points

this is a question specific to the "Coding the Blog Homepage 15:52" video in the "Adding a Blog to a WordPress Theme" section.

1 Answer

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hi!

You might want to check out our course on WordPress Hooks - Actions and Filters for a more in depth understanding of what's going on here. It comes later in the WordPress Development Track.