Advertisement
Guest User

Untitled

a guest
Feb 24th, 2012
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.51 KB | None | 0 0
  1. // Custom Excerpt length
  2.  
  3. remove_filter( 'excerpt_length', 'twentyten_excerpt_length' );
  4.  
  5. function finest_excerpt_length( $length ) {
  6.     return 20;
  7. }
  8. add_filter( 'excerpt_length', 'finest_excerpt_length', 999 );
  9.  
  10. /**
  11.  * Returns a "Continue Reading" link for excerpts
  12.  *
  13.  * @since Twenty Ten 1.0
  14.  * @return string "Continue Reading" link
  15.  */
  16. function twentyten_continue_reading_link() {
  17.     return ' <a href="'. get_permalink() . '">' . __( 'Continue reading', 'twentyten' ) . '</a>';
  18. }
  19.  
  20. /**
  21.  * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyten_continue_reading_link().
  22.  *
  23.  * To override this in a child theme, remove the filter and add your own
  24.  * function tied to the excerpt_more filter hook.
  25.  *
  26.  * @since Twenty Ten 1.0
  27.  * @return string An ellipsis
  28.  */
  29. function twentyten_auto_excerpt_more( $more ) {
  30.     return ' &hellip;' . twentyten_continue_reading_link();
  31. }
  32. add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
  33.  
  34. /**
  35.  * Adds a pretty "Continue Reading" link to custom post excerpts.
  36.  *
  37.  * To override this link in a child theme, remove the filter and add your own
  38.  * function tied to the get_the_excerpt filter hook.
  39.  *
  40.  * @since Twenty Ten 1.0
  41.  * @return string Excerpt with a pretty "Continue Reading" link
  42.  */
  43. function twentyten_custom_excerpt_more( $output ) {
  44.     if ( has_excerpt() && ! is_attachment() ) {
  45.         $output .= twentyten_continue_reading_link();
  46.     }
  47.     return $output;
  48. }
  49. add_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement