5

Disable Auto Jump in WordPress’s Read More


The ‘Read More’ or post summary feature has now become a standard on many blogs based on WordPress or otherwise. However one glitch with this feature, which is rather overlooked by newbie theme developers, is that , by default, when a visitor click on the Read More link, the web page loads and then automatically forwards or jumps to the spot where the tag is set in the post, skipping all the content above it.

I personally found it a little uncomfortable, considering that my blog name subscribe panel and advertisements were just skipped away.

So here’s how to remove it. There are two ways to achieve this.

  1. Editing theme file (recommended)

    This is very simple. From your wordpress theme editor (Appearence >> Editor) select the functions.php file of your active(current) theme. Now just paste the following code before the ending ?> tag:

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

    Note: The only thing is that you must update your functions.php file any time you change your blogs theme.

  2. Editing WordPress core file

    This method is also pretty easy, however it includes you editing WordPress’s core file. From your FTP software or file manager just go to the wp-includes folder and look for post-template.php (in WordPress 2.1+) or template-functions-post.php and search for:

    $output .= %u2018 <a href="%u2019. get_permalink() . "#more-$id\">$more_link_text</a>";

    and replace the above line with:

    $output .= %u2018 <a href="%u2019. get_permalink() ."\">$more_link_text</a>";

    or

    $output .= %u2018 <a href="%u2019. get_permalink() ."%u201D>$more_link_text</a>%u2019;

    Note: Whenever you update your WordPress installation, these changes will be over-written. So you will have to make the changes every-time your WordPress is updated.

That’s it. A pretty useful change, believe me.


Filed in: Wordpress Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Related Posts

Bookmark and Promote!

5 Responses to "Disable Auto Jump in WordPress’s Read More"

  1. Thanks Richie Sajan.

    The first method helped me and you’ve explained those steps clearly.

  2. Daniel says:

    Thanks a lot, just what I was looking for!

Leave a Reply

Submit Comment

© 2012 Tech With Ric. All rights reserved. XHTML / CSS Valid.