Created
January 26, 2012 19:50
-
-
Save rachelbaker/1684691 to your computer and use it in GitHub Desktop.
WordPress Excerpt Related Functions from TwentyTen Theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Sets the post excerpt length to 40 characters. | |
*/ | |
function twentyten_excerpt_length( $length ) { | |
return 40; | |
} | |
add_filter( 'excerpt_length', 'twentyten_excerpt_length' ); | |
/** | |
* Returns a "Continue Reading" link for excerpts | |
* @return string "Continue Reading" link | |
*/ | |
function twentyten_continue_reading_link() { | |
return ' <a href="'. get_permalink() . '">' . __( '<div style="text-align:right; clear:both;">Read full post</div>', 'twentyten' ) . '</a>'; | |
} | |
/** | |
* Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyten_continue_reading_link(). | |
*/ | |
function twentyten_auto_excerpt_more( $more ) { | |
return ' …' . twentyten_continue_reading_link(); | |
} | |
add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' ); | |
/** | |
* Adds a pretty "Continue Reading" link to custom post excerpts. | |
*/ | |
function twentyten_custom_excerpt_more( $output ) { | |
if ( has_excerpt() && ! is_attachment() ) { | |
$output .= twentyten_continue_reading_link(); | |
} | |
return $output; | |
} | |
add_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment