Prevent Page Scroll when clicking the More Link
-
Thank you for your help! I would like to prevent the default page scroll function when clicking the More Link on a wordpress.com blog I’ve created. Is that possible?
I found this but, don’t know if it is apropos to wordpress.com?:
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’ );The blog I need help with is: (visible only to logged in users)
-
Hi there,
I’m afraid the code you included in your question won’t work on WordPress.com, but I still may be able to help.
Could you send me a link to a page where you are using the more link?
It would also be helpful if you could tell me what you want to happen when users click the link.
Thanks!
-
Thank you so very much! https://nourishingourchildren.wordpress.com – if you scroll down to the article “It all started in Lötschental, Switzerland” you’ll see that I attempted to use it there but, when I click on the read more link – it doesn’t land at the top of the article, which is what I want. I would be most grateful for your help!
-
I did some digging, and there isn’t a way to make the more tag behave the way you describe on WordPress.com.
The reason it behaves the way it does is when readers click the “more” link, they’ve already read the first part of the article. If you link to the top of the article they have to scroll through the part they already read to figure out where they are.
This way, they go right to where they left off, and if they need some context, they can scroll up the page to see the rest of the post.
Does that make sense?
-
I understood all that already but, it is not landing exactly to where one leaves off before the “read more” … it is not very precise and in any case I really don’t want to use this feature. The question I posed is not why is this feature in place but, rather, I expressed that I to change it. Can it be changed with html code?! I want what my friends have: http://nourishedkitchen.com and http://www.mommypotamus.com
The first few sentences allow the reader to decide if they want to read the article.
-
I’m sorry not to have better news. Your friends both have self-hosted WordPress sites, so they have the ability to change the code on their sites, in a way you don’t.
This article explains a little more about the differences between sites hosted on WordPress.com and self-hosted WordPress sites.
- The topic ‘Prevent Page Scroll when clicking the More Link’ is closed to new replies.