WordPress.org

Make WordPress Core

Ticket #13361: fancy_excerpts.diff

File fancy_excerpts.diff, 1.4 KB (added by iandstewart, 5 years ago)

Filter the traditional "[…]" in excerpts with an empty string and adds a fancy "Continue reading link" to both trimmed excerpts AND custom excerpts.

  • functions.php

     
    244244add_filter( 'excerpt_length', 'twentyten_excerpt_length' ); 
    245245 
    246246/** 
    247  * Sets the "read more" link to something pretty. 
     247 * Removes the traditional "[…]" for marking of excerpts 
    248248 * 
     249 * @since Twenty Ten 1.0 
     250 * @return remove the traditional "[…]" for marking of excerpts 
     251 */ 
     252function twentyten_remove_ellipses( $more ) { 
     253        return ''; 
     254} 
     255add_filter( 'excerpt_more', 'twentyten_remove_ellipses' ); 
     256 
     257/** 
     258 * Adds a pretty "Continue Reading" link to post excerpts 
     259 * 
    249260 * To override this link in a child theme, remove the filter and add your own 
    250261 * function tied to the excerpt_more filter hook. 
    251262 * 
    252263 * @since Twenty Ten 1.0 
    253264 * @return string A pretty 'Continue reading' link. 
    254265 */ 
    255 function twentyten_excerpt_more( $more ) { 
    256         return ' &hellip; <a href="'. get_permalink() . '">' . __('Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten') . '</a>'; 
     266function twentyten_excerpt_more($output) { 
     267        return $output . ' &hellip; <a href="'. get_permalink() . '">' . __('Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten') . '</a>'; 
    257268} 
    258 add_filter( 'excerpt_more', 'twentyten_excerpt_more' ); 
     269add_filter( 'get_the_excerpt', 'twentyten_excerpt_more' ); 
    259270 
    260271/** 
    261272 * Remove inline styles printed when the gallery shortcode is used.