From 84739b1583f9557b7425971f861ef2628ca63ded Mon Sep 17 00:00:00 2001 From: wpmuguru Date: Fri, 28 May 2010 17:01:27 +0000 Subject: [PATCH] continue reading link on custom excerpt in TwentyTen, props iandstewart, fixes #13361 git-svn-id: http://svn.automattic.com/wordpress/trunk@15040 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-content/themes/twentyten/functions.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/wp-content/themes/twentyten/functions.php b/wp-content/themes/twentyten/functions.php index 6a4a0dcbe..5cde25435 100644 --- a/wp-content/themes/twentyten/functions.php +++ b/wp-content/themes/twentyten/functions.php @@ -249,7 +249,17 @@ function twentyten_excerpt_length( $length ) { add_filter( 'excerpt_length', 'twentyten_excerpt_length' ); /** - * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis. + * Returns a "Continue Reading" link for excerpts + * + * @since Twenty Ten 1.0 + * @return string "Continue Reading" link + */ +function twentyten_continue_reading_link() { + return ' ' . __( 'Continue reading ', 'twentyten' ) . ''; +} + +/** + * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyten_continue_reading_link(). * * To override this in a child theme, remove the filter and add your own * function tied to the excerpt_more filter hook. @@ -258,12 +268,12 @@ add_filter( 'excerpt_length', 'twentyten_excerpt_length' ); * @return string An ellipsis */ function twentyten_auto_excerpt_more( $more ) { - return ' …'; + return ' …' . twentyten_continue_reading_link(); } add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' ); /** - * Adds a pretty "Continue Reading" link to post excerpts. + * Adds a pretty "Continue Reading" link to custom post excerpts. * * To override this link in a child theme, remove the filter and add your own * function tied to the get_the_excerpt filter hook. @@ -272,7 +282,10 @@ add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' ); * @return string Excerpt with a pretty "Continue Reading" link */ function twentyten_custom_excerpt_more( $output ) { - return $output . ' ' . __( 'Continue reading ', 'twentyten' ) . ''; + if ( has_excerpt() ) { + $output .= twentyten_continue_reading_link(); + } + return $output; } add_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );