Support » Fixing WordPress » Changing the #more-ID anchor for Read more… link

  • Resolved Maujor


    Hi all,
    I use the quicktag more <!–more–> for display the first paragraph of the post on the index.php

    So, I get the “Read more…” or “Continue reading…” link that points to the whole post. That link, points to an anchor in the post-usually named #more-ID that goes to the 2nd paragraph in the page’s post.

    Question is: How to change the link to the very top of the page? (Say to the id of the title post – ususally something like <h2 id="post-#>Post title</h2>

    I need replace the anchor #more-ID by #post-ID


Viewing 4 replies - 1 through 4 (of 4 total)
  • Add this to your theme’s functions.php file or put it in a plugin:

    function replace_the_more($content) {
    return preg_replace('/\#more-(\d)/',"#post-$1",$content);

    Hello filosofo,
    Plugin option works like a charm, 🙂
    Thanks for share.
    For further information, sharing with others:
    The plugin code:
    Plugin Name: more_replace
    Description: Replace de #more-ID anchor by #post-ID anchor.
    Author: Filosofo
    Author URI:
    Plugin URI:
    your code here...

    Just for ref, here’s a plugin that already existed:

    Is there a case where a page contains more than one article? That would explain the #post-ID in the url. If it’s only one article per page, wouldn’t this be just as good?

    function replace_the_more($content) {
    return preg_replace('/#more-(d)/','',$content);

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Changing the #more-ID anchor for Read more… link’ is closed to new replies.