Make WordPress Core

Ticket #30024: 30024.diff

File 30024.diff, 2.1 KB (added by kraftbj, 11 years ago)

Add Continued Reading link

  • src/wp-content/themes/twentyfifteen/functions.php

     
    310310}
    311311add_filter( 'walker_nav_menu_start_el', 'twentyfifteen_nav_description', 10, 4 );
    312312
     313if ( ! function_exists( 'twentyfifteen_continue_reading_link' ) ) :
    313314/**
     315 * Return a "Continue Reading" link for excerpts
     316 *
     317 * @since Twenty Fifteen 1.0
     318 *
     319 * @return string The "Continue Reading" HTML link.
     320 */
     321function twentyfifteen_continue_reading_link() {
     322        return ' <a href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyfifteen' ) . '</a>';
     323}
     324endif; // twentyfifteen_continue_reading_link
     325
     326/**
     327 * Replace "[...]" in the Read More link with an ellipsis.
     328 *
     329 * The "[...]" is appended to automatically generated excerpts.
     330 *
     331 * To override this in a child theme, remove the filter and add your own
     332 * function tied to the excerpt_more filter hook.
     333 *
     334 * @since Twenty Fifteen 1.0
     335 *
     336 * @param string $more The Read More text.
     337 * @return The filtered Read More text.
     338 */
     339function twentyfifteen_auto_excerpt_more( $more ) {
     340        return ' &hellip;' . twentyfifteen_continue_reading_link();
     341}
     342add_filter( 'excerpt_more', 'twentyfifteen_auto_excerpt_more' );
     343
     344/**
     345 * Add a pretty "Continue Reading" link to custom post excerpts.
     346 *
     347 * To override this link in a child theme, remove the filter and add your own
     348 * function tied to the get_the_excerpt filter hook.
     349 *
     350 * @since Twenty Fifteen 1.0
     351 *
     352 * @param string $output The "Continue Reading" link.
     353 * @return string The filtered "Continue Reading" link.
     354 */
     355function twentyfifteen_custom_excerpt_more( $output ) {
     356        if ( has_excerpt() && ! is_attachment() && !is_admin() ) {
     357                $output .= twentyfifteen_continue_reading_link();
     358        }
     359        return $output;
     360}
     361add_filter( 'get_the_excerpt', 'twentyfifteen_custom_excerpt_more' );
     362
     363/**
    314364 * Implement the Custom Header feature.
    315365 *
    316366 * @since Twenty Fifteen 1.0