Mare Digitale

digital creative

When developing my new WordPress site theme, I came to the issue of the_content link opening the post and scrolling to the place of <!— more —>. I didn’t want it and it is quite easy to prevent the scroll! Simply filter the more link with a regular expression.

Add to the theme functions.php:
function remove_more_link_scroll( $link ) {
$link = preg_replace( ‘|#more-[0-9]+|’, ”, $link ); return $link;}add_filter( ’the_content_more_link’, ‘remove_more_link_scroll’ );

The named anchors are gone!