[Resolved] Prevent Page Scroll When Clicking the More Link

Home Forums Support [Resolved] Prevent Page Scroll When Clicking the More Link

Home Forums Support Prevent Page Scroll When Clicking the More Link

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #161612
    Erica

    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.

    #161693
    Tom
    Lead Developer
    Lead Developer
    #161699
    Erica

    It works perfectly!!!

    I really like GP.
    Thanks a lot.

    #161700
    Tom
    Lead Developer
    Lead Developer

    You’re welcome! ๐Ÿ™‚

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.