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 Hooks - Actions and Filters Filter Functions in WordPress Real World Examples of WordPress Filters

Nathaniel Miller
Nathaniel Miller
8,802 Points

There's 3 parameters, $title, $sep, and $seplocation. Why does he say there's only 2 and go on to ignore $seplocation?

When adding his wp_title filter the instructor poses the question "How do we know there are two parameters?". So he does a search for 'apply filter...' and comes with up with a line that shows three parameters. Then he says there are two and goes onto ignore the last one. Why is that?

2 Answers

When you make the search it positions you at this line of code:

$title = apply_filters( 'wp_title', $title, $sep, $seplocation );

But you are only at the position of the function, going up the function you would notice that there are default values:

function wp_title( $sep = '»', $display = true, $seplocation = '' ) {
  ...
}

The $seplocation is blank at the default section.

Glenré Charl Labuschagné
Glenré Charl Labuschagné
23,204 Points

In short he is only setting 2 required parameters for the function custom_wp_title( $title, $sep) and ignoring (leaving) the default $seplocation parameter.