Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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.