I’m trying to learn HOW to learn about WordPress by following its source code etc.
I’m really stumped at the_excerpt(). Documentation states that the_excerpt uses get_the_excerpt(), and will return either the (manual) excerpt, or will use the first 55 characters of the_content.
I’m interested in the logic that looks first for the manual excerpt and then decides whether it needs to go in and extract a substring from the post content. But I can’t find it.
In post-template.php, we see the_excerpt() and get_the_excerpt() defined.
the_excerpt() does nothing more than echo out get_the_excerpt():
249 function the_excerpt() {
250 echo apply_filters('the_excerpt', get_the_excerpt());
251 }
get_the_excerpt() seems to do nothing more than grab the post_excerpt column from the wp_post table:
261 function get_the_excerpt( $deprecated = '' ) {
262 if ( !empty( $deprecated ) )
263 _deprecated_argument( __FUNCTION__, '2.3' );
264
265 global $post;
266 $output = $post->post_excerpt;
267 if ( post_password_required($post) ) {
268 $output = __('There is no excerpt because this is a protected post.');
269 return $output;
270 }
271
272 return apply_filters('get_the_excerpt', $output);
273 }
I don’t see where the logic to grab $post->post_content resides. Is it in the filters? I can’t see those filters defined anywhere, but this may be because I just don’t know where to look.
A cursory glance at Adam Brown’s source code search site doesn’t seem to be turning up any definitions either.
Can someone help me pick up the thread and figure this out? Remember, I’m more interested in how to figure it out than I am in the actual answer.
I appreciate everyone’s input.
Tom
From what I understand in the default-filters.php file a filter is applied to the ‘get_the_filter’ filter. The callback is for a method called ‘wp_trim_execrpt’. This is found in formatting.php. From there you can see the logic. Hope that helps.