Archived topic
Remove anchor from readmore link
3 replies · Started by mkjj on August 28, 2021
I use this snippet to create a readmore button on the blog page:
add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
function tu_excerpt_metabox_more( $excerpt ) {
if ( is_front_page() ) {
$output = $excerpt;
return $output;
}
else {
$output = $excerpt;
if ( has_excerpt() ) {
$output = sprintf( '%1$s <p class="read-more-container"><a class="read-more button" href="%2$s">%3$s</a></p>',
$excerpt, get_permalink(), __( 'Mehr lesen', 'generatepress' ));
}
return $output;
}
}
Now, the standard WP behaviour is to add an anchor to the link like domain.com/post#more-12345
Usually, this can be disabled with this snippet:
function remove_more_jump_link($link) {
$offset = strpos($link, '#more-');
if ($offset) {
$end = strpos($link, '"',$offset);
}
if ($end) {
$link = substr_replace($link, '', $offset, $end-$offset);
}
return $link;
}
add_filter('the_content_more_link', 'remove_more_jump_link');
But this does not work in my case. How would I remove this anchor?
Thank you very much!
Hi there,
try the GP Filter to remove the more jump:
Wow! I know that you guys are good. But I'm again and again impressed by this awesome support. Works like a charm!
Thank you very much!
Glad we can be of help :)