Support » Theme: The Bootstrap » Removing the excerpt "continue reading" link

  • Resolved Philip John



    I’m using a page template in my Bootstrap child theme to display a list of custom posts with an excerpt. Each excerpt has the “continue reading” link on, which I’d like to remove.

    Having look in the parent functions.php it tells me to simply remove the two filters (hooking into excerpt_more and get_the_excerpt) to get rid of this.

    So, in my child functions.php I have the following;

    remove_filter( 'get_the_excerpt', 'the_bootstrap_custom_excerpt_more' );
    remove_filter( 'excerpt_more', 'the_bootstrap_auto_excerpt_more' );

    However, the “continue reading” link remains. I have tried adding the priority parameter, using 10, 1, 11 and 20 as values but that made no difference.

    Commenting out the add_filter() calls in the parent functions.php appears to be the only way to get the link to go away.

    This is one of those “I can’t understand why it won’t work!” scenarios so I’m guessing the solution is starring me in the face…any help opening my eyes is appreciated!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hello,

    your child theme functions.php is loaded first, so you can’t undo things that have not been done yet 🙂

    you have to use ‘after_setup_theme’ hook

    function undo_filters() {
    add_action( 'after_setup_theme', 'undo_filters' );

    some good reading:


    Told ya – staring me in the face! Thanks 🙂

    So, I’m trying to remove the Continue Reading link too. I put this in my child theme’s functions.php and I’m still getting a Continue Reading link. Did I miss something here? Thanks.

    function remove_excerpt_more_link() {
    	remove_filter( 'get_the_excerpt', 'the_bootstrap_custom_excerpt_more' );
    	remove_filter( 'excerpt_more', 'the_bootstrap_auto_excerpt_more' );
    add_action( 'after_setup_theme', 'remove_excerpt_more_link' );

    @jmjf Silly question but, you’ve definitely activated your child and not bootstrap, yes?

    Yep. It’s definitely my child theme (looks very different from Bootstrap default). I guess one question might be: how should I be pulling the excerpt? I’m using the_excerpt() because that’s what’s in the default partials/content.php. Should I be using one of the other excerpt options?

    my clear way:

    function hwlab_excerpt_txt() {
    	remove_filter( 'get_the_excerpt', 'the_bootstrap_custom_excerpt_more' );

    it work fine fore me.

    As I was experimenting last night, I found that get_the_excerpt will attempt to put the link in (even if I remove filter), and if the excerpt is short, that can mess up the HTML. I modified an example function from codex to grab the post’s excerpt text directly rather than use functions. If there is no excerpt, grab the first chunk of the article with a little extra. Then whack it down to the desired length, always terminating on a whole word.

    function the_excerpt_max_charlength($charlength) {
    	$post = get_post();
    	$excerpt = $post->post_excerpt;
    	if (mb_strlen($excerpt) == 0) $excerpt = mb_substr($post->post_content, 0, $charlength + 5);
    	if ( mb_strlen( $excerpt ) > $charlength ) {
    		$subex = mb_substr( $excerpt, 0, $charlength - 5);
    		$exwords = explode( ' ', $subex );
    		$excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
    		if ( $excut < 0 ) {
    			echo mb_substr( $subex, 0, $excut );
    		} else {
    			echo $subex;
    	} else {
    		echo $excerpt;
    	echo ' [. . .]';

    FranceImage’s suggestion above worked perfectly for me, thank you!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Removing the excerpt "continue reading" link’ is closed to new replies.