For every filter or action hook that you use with the add_filter
or add_action
functions, there is a corresponding apply_filters
or do_action
function called somewhere in the WordPress core. This function sets up which parameters will be sent to the filter or action.
For the filter hook the_content
example that you gave, the filter hook is used in the function the_content
found in wp-includes\post-template.php
in WordPress 3.7.1:
function the_content( $more_link_text = null, $strip_teaser = false) {
$content = get_the_content( $more_link_text, $strip_teaser );
$content = apply_filters( 'the_content', $content );
$content = str_replace( ']]>', ']]>', $content );
echo $content;
}
In the apply_filters
function call, the first parameter is the hook name, in this case 'the_content'
. The next parameter, $content
, is the value that we want to filter. This will be the first parameter in your filter function (which is named $content
in your my_the_content_filter
function, but it could have any name). Optionally, more parameters can be specified in the apply_filters
function, and these will be passed in additional input parameters to the filter function.
For a filter hook, your filter function returns a filtered value, which in turn is returned by the apply_filters
function. For action hooks, there isn’t any return value used.