I’ve tried to remove the meta-nav arrow from end of my “Read more”.
I’m building a child theme on top of Twenty Fourteen and have used
// Change excerpt length
function new_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'new_excerpt_length' );
// Replaces the excerpt "Read More" text by a link
function new_excerpt_more( $more ) {
global $post;
return '<a class="more-link" href="'. get_permalink($post->ID) . '">Fortsett å lese</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
But it doesn’t work! The arrow is still there.
I’ve read in the codex that some of WordPress themes have their own filter settings on “Read More”, and that I need to use remove_filter() to remove them. I tried using the filter from https://codex.wordpress.org/Customizing_the_Read_More
I’ve searched the function.php for anything that includes the word excerpt, read more or twentyfourteen filter, but didn’t find anything.
In the twenty fourteen theme there is a plugable function named twentyfourteen_excerpt_more
which generates the read more links. This function can be overridden in your child theme to use your custom read more link. All you need to do is add the following to your child theme’s functions.php file:
/**
* Overrides the parent function that generates the read more links
*
* @param string $more
*
* @return string
*/
function twentyfourteen_excerpt_more( $more ) {
global $post;
return '<a class="more-link" href="'. get_permalink($post->ID) . '">Fortsett å lese</a>';
}
add_filter( 'excerpt_more', 'twentyfourteen_excerpt_more' );
Just for reference the parent function is located in twentyfourteen/inc/template-tags.php
and looks like this:
if ( ! function_exists( 'twentyfourteen_excerpt_more' ) && ! is_admin() ) :
/**
* Replaces "[...]" (appended to automatically generated excerpts) with ...
* and a Continue reading link.
*
* @since Twenty Fourteen 1.3
*
* @param string $more Default Read More excerpt link.
* @return string Filtered Read More excerpt link.
*/
function twentyfourteen_excerpt_more( $more ) {
$link = sprintf( '<a href="https://wordpress.stackexchange.com/questions/242087/%1$s" class="more-link">%2$s</a>',
esc_url( get_permalink( get_the_ID() ) ),
/* translators: %s: Name of current post */
sprintf( __( 'Continue reading %s <span class="meta-nav">→</span>', 'twentyfourteen' ), '<span class="screen-reader-text">' . get_the_title( get_the_ID() ) . '</span>' )
);
return ' … ' . $link;
}
add_filter( 'excerpt_more', 'twentyfourteen_excerpt_more' );
endif;