| | 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 | */ |
| | 321 | function twentyfifteen_continue_reading_link() { |
| | 322 | return ' <a href="'. esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">→</span>', 'twentyfifteen' ) . '</a>'; |
| | 323 | } |
| | 324 | endif; // 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 | */ |
| | 339 | function twentyfifteen_auto_excerpt_more( $more ) { |
| | 340 | if ( ! is_admin() ) { |
| | 341 | return ' …' . twentyfifteen_continue_reading_link(); |
| | 342 | } |
| | 343 | return $more; |
| | 344 | } |
| | 345 | add_filter( 'excerpt_more', 'twentyfifteen_auto_excerpt_more' ); |
| | 346 | |
| | 347 | /** |
| | 348 | * Add a pretty "Continue Reading" link to custom post excerpts. |
| | 349 | * |
| | 350 | * To override this link in a child theme, remove the filter and add your own |
| | 351 | * function tied to the get_the_excerpt filter hook. |
| | 352 | * |
| | 353 | * @since Twenty Fifteen 1.0 |
| | 354 | * |
| | 355 | * @param string $output The "Continue Reading" link. |
| | 356 | * @return string The filtered "Continue Reading" link. |
| | 357 | */ |
| | 358 | function twentyfifteen_custom_excerpt_more( $output ) { |
| | 359 | if ( has_excerpt() && ! is_attachment() && ! is_admin() ) { |
| | 360 | $output .= twentyfifteen_continue_reading_link(); |
| | 361 | } |
| | 362 | return $output; |
| | 363 | } |
| | 364 | add_filter( 'get_the_excerpt', 'twentyfifteen_custom_excerpt_more' ); |
| | 365 | |
| | 366 | /** |