[resolved] Changing the #more-ID anchor for Read more... link (5 posts)

  1. Maujor
    Posted 9 years ago #

    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


  2. Austin Matzko
    Posted 9 years ago #

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

  3. Maujor
    Posted 9 years ago #

    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: http://www.ilfilosofo.com/blog
    Plugin URI: http://wordpress.org/support/topic/72388?replies=2#post-378516
    your code here...

  4. Chris_K
    Posted 9 years ago #

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

  5. cwd
    Posted 9 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.