Site logo

Archived topic

Prevent Page Scroll When Clicking the More Link

3 replies · Started by Erica on December 23, 2015

Viewing posts 1–4 of 4

Hi there,

I want to apply this, but it not working while I paste code in function.php. Where should I paste this code, or what can I do?

http://codex.wordpress.org/Customizing_the_Read_More

Prevent Page Scroll When Clicking the More Link

By default, clicking the .more-link anchor opens the web document and scrolls the page to section of the document containing the named anchor (#more-000). This section is where writers choose to place the <!--more--> tag within a post type.

Users can prevent the scroll by filtering the content more link with a simple regular expression.

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' );

Simply add the above code to the theme's functions.php file and the named anchors are no more.

It works perfectly!!!

I really like GP.
Thanks a lot.

You're welcome! :)

This archived topic is closed to new replies.