Advertisement
Digitalraindrops

Twenty Eleven Custom Readmore

Mar 25th, 2012
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. <?php
  2. /** This action will run the function below after the theme has been setup */
  3. add_action( 'after_setup_theme', 'child_theme_setup' );
  4.  
  5. /** This function will hold our new calls and over-rides */
  6. if ( !function_exists( 'child_theme_setup' ) ):
  7. function child_theme_setup() {
  8.    
  9.     /**  
  10.     *Change the "Continue Reading" link to post excerpts.          
  11.     * Returns a "Read More" link for excerpts
  12.     */
  13.     function child_continue_reading_link() {
  14.         return ' <a href="'. esc_url( get_permalink() ) . '">' . __( 'Read More <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) . '</a>';
  15.     }
  16.     /** remove the existing filters  */
  17.     remove_filter( 'get_the_excerpt', 'twentyeleven_custom_excerpt_more' );
  18.     remove_filter( 'excerpt_more', 'twentyeleven_auto_excerpt_more' );
  19.    
  20.     /** Add the new filters */
  21.     function child_auto_excerpt_more( $more ) {
  22.         return '<br/> &hellip;' . child_continue_reading_link();
  23.     }
  24.     add_filter( 'excerpt_more', 'child_auto_excerpt_more' );
  25.  
  26.     function child_custom_excerpt_more( $output ) {
  27.         if ( has_excerpt() && ! is_attachment() ) {
  28.             $output .= child_continue_reading_link();
  29.         }
  30.         return $output;
  31.     }
  32.     add_filter( 'get_the_excerpt', 'child_custom_excerpt_more' );
  33. }          
  34. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement