the_title

the_title is a filter on post titles. It is a little bit bizarre.

Here is the first usage, in the_title()

Context:

File: wp-includes/template-functions-post.php
function the_title($before = '', $after = '', $echo = true) {
	$title = get_the_title();
	if ( strlen($title) > 0 ) {
		$title = apply_filters('the_title', $before . $title . $after, $before, $after);
		if ($echo)
			echo $title;
		else
			return $title;
	}
}

And here is the second usage (also the same in next_post_link()):

Context:

File: wp-includes/template-functions-links.php
function previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
  $post = get_previous_post($in_same_cat, $excluded_categories);

  if(! $post) {
    return;
  }

  $title = apply_filters('the_title', $post->post_title, $post);

  $string = '<a href="'.get_permalink($post->ID).'">';

  $link = str_replace('%title', $title, $link);

  $link = $string . $link . '</a>';

  $format = str_replace('%link', $link, $format);

  echo $format;
}

This hook can pass multiple parameters. In order to get additional parameters (up to 3 for this hook) passed to your function, you will have to hook in like this: add_filter('the_title', 'your_function', 10, 3); where 10 is your function's priority, and 3 is the number of parameters you want your function to accept. Note that your function should only return the first parameter.

This hook is a filter which means that information is passed through it, and then used by WordPress. Your function needs to accept that information, and return it. Using add_filter('the_title', 'your_function'); helps you to remember this distinction. When you are passing an ID, it is assumed that you will return the ID as it was given to you. With filters that pass strings or arrays, you may manipulate the information before passing it along.