I'm looking to modify the output of the_excerpt when there isn't an excerpt specified and the post is password protected. I already can modify the password protected form to whatever I want, but the_excerpt is outputting "There is no excerpt because this is a protected post.".
The code for this lies in wp-includes/post-template.php:
function get_the_excerpt( $deprecated = '' ) {
if ( !empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '2.3' );
global $post;
$output = $post->post_excerpt;
if ( post_password_required($post) ) {
$output = __('There is no excerpt because this is a protected post.');
return $output;
}
return apply_filters('get_the_excerpt', $output);
}
An easy solution would be to simply change the code in there and move on, but as well all know, changing core files deserves more than a slap across the face! Can anyone help me figure out how to modify this code in my functions.php file?
Thanks!
EDIT: Here's the code I tried out, but it isn't working :(
add_filter('get_the_excerpt', 'improved_get_the_excerpt');
function improved_get_the_excerpt( $deprecated = '' ) {
if ( !empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '2.3' );
global $post;
$output = $post->post_excerpt;
if ( post_password_required($post) ) {
$output = __('This is some test content.');
return $output;
}
}
I'm completely new to the concept of filters, actions, hooks, etc so please bear with me! I appreciate the help!