Change “Continue reading →” of Twenty Eleven WordPress Theme from its Child Theme functions.php

I found it’s hard to change “Continue reading →” text after an Excerpt in WordPress  default Twenty Eleven theme from my child theme. It should be done from child theme’s functions.php

Here’s the code:

/***************************************
 * Change CONTINUE READING to READ MORE
 **************************************/

/********* CUSTOM EXCERPTS ************/

/* Removes the get_the_exerpt filter */
function iggy_remove_excerpt_filter() {
   remove_filter( 'get_the_excerpt', 'twentyeleven_custom_excerpt_more' );
}
add_action( 'after_setup_theme', 'iggy_remove_excerpt_filter' );

/* Adds a pretty "READ MORE" link to custom post excerpts  */

function iggy_custom_excerpt_more( $output ) {
	if ( has_excerpt() && ! is_attachment() ) {
		$output .= iggy_continue_reading_link();
	}
	return $output;
}
add_filter( 'get_the_excerpt', 'iggy_custom_excerpt_more' );

/*********** AUTO EXCERPTS **********/

/* Removes the excerpt_more filter */

function iggy_remove_auto_excerpt_filter() {
   remove_filter( 'excerpt_more', 'twentyeleven_auto_excerpt_more' );
}
add_action( 'after_setup_theme', 'iggy_remove_auto_excerpt_filter' );

/* Adds a pretty "READ MORE" link to custom post excerpts. */

function iggy_auto_excerpt_more( $more ) {
	return '… ' . iggy_continue_reading_link();
}
add_filter( 'excerpt_more', 'iggy_auto_excerpt_more' );

/* Returns a "READ MORE" link */
function iggy_continue_reading_link() {
	return ' <a href="'. esc_url( get_permalink() ) . '">' . __( 'Read More <span class="meta-nav">→</span>', 'twentyeleven' ) . '</a>';
}

 

 

Share:
This entry was posted in WordPress and tagged . Bookmark the permalink.

6 Responses to Change “Continue reading →” of Twenty Eleven WordPress Theme from its Child Theme functions.php

  1. Like a charm. Thanks a lot for this, been looking for an hour for a good solution. Thumbs up!

  2. Avi says:

    Thank you! You helped me a lot.

  3. Caitlin says:

    Thanks so much! I tried changing it in the content.php like other tutorials said, but it didn’t seem to work. This was just what I needed. 🙂

  4. Pino says:

    Thank you so much! x)

  5. Das Chan says:

    If pasting this into your child theme’s functions.php doesn’t do it for you, don’t forget to also change the text in the child theme’s loop.php. I was scratching my head, wondering why the functions were not working, till I came across this post in wordpress.org by alchymyth, The Sweeper & Moderator. Editing the child theme’s loop.php finally kicked it into gear.

  6. Kristin says:

    Thank you for this! I couldn’t figure it out.

Leave a Reply

Your email address will not be published. Required fields are marked *