Doc WordPress WordPress Tricks, Tips & Snippets

21Sep/150

Remove “#more-123” anchor from “Read more” links

By default WordPress automatically adds "#more-123" anchor links to the "Read more" links on post excerpts on all overview pages, causing the new page to jump down to that anchor once it has loaded. This behaviour might not be wanted and it is easy to fix.

Just add this to your theme's functions.php file:

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');
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.