• Hi,
    I’ve been looking around the forums both here and at cyberchimps, but am struggling to edit/remove the read-more link to specific posts produced by category blogroll templates. I’m using the free responsive theme, but trying to intervene via a child theme.

    I’ve identified the call to get the except which is simply;
    <?php the_excerpt(); ?>
    in my child version of a category template copied from the original template.

    I’ve identified in the responsive themes own functions where the read-more button is created:

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. Or better still – use the pastebin ]

    function responsive_read_more() {
    	return '<div class="read-more"><a href="' . get_permalink() . '">' . __( 'Read more ›', 'responsive' ) . '</a></div><!-- end of .read-more -->';
    }
    
    /**
     * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and responsive_read_more_link().
     */
    function responsive_auto_excerpt_more( $more ) {
    	return '<span class="ellipsis">…</span>' . responsive_read_more();
    }
    
    add_filter( 'excerpt_more', 'responsive_auto_excerpt_more' );
    
    What I am trying to change via my child functions is the below. Basically I'd like it to check if this is happening in a specific category and not show a read-more button.
    
    function responsive_child_read_more() {
    	if ( in_category('sound-news') ) {
            // do not show a read more button!!!
    	} else {
    	return '<div class="read-more"><a href="' . get_permalink() . '">' . __( 'Read more ›', 'responsive' ) . '</a></div><!-- end of .read-more -->';
    }
    }
    
    What is the best way to do this?
    So far I've only had limited success using:
    
    add_action('after_setup_theme', 'child_read_more_filter');
    function child_read_more_filter() {
           add_filter('the_excerpt','responsive_child_read_more');
    }

    …BUT – This removes the excerpt entirely, while

    add_filter('excerpt_more'...

    achieves nothing.

    Any help – greatly appreciated.

    [ Please do not bump, that’s not permitted here. ]

Viewing 1 replies (of 1 total)
  • Responsive theme adds read more links through excerpt filter.
    Add code below in your theme’s functions.php file.

    /******************************************************************************
     * Remove Read More links
     */
    add_action('after_setup_theme', function(){
        remove_filter( 'excerpt_more', 'responsive_auto_excerpt_more' );
        remove_filter( 'get_the_excerpt', 'responsive_custom_excerpt_more' );
    });
    
    add_filter( 'excerpt_more', function ( $more ) {
    	return '<span class="ellipsis">&hellip;</span>';
    });

    Hope it helps.

Viewing 1 replies (of 1 total)

The topic ‘Removing read-more from excerpt (responsive theme)’ is closed to new replies.