• Hi everyone.

    I’m trying to customize the “read more” link on my site. I added this snippet from the codex page to the bottom of my functions.php file:

    add_filter( 'the_content_more_link', 'modify_read_more_link' );
    function modify_read_more_link() {
    return '<a class="more-link" href="' . get_permalink() . '">Your Read More Link Text</a>';
    }

    It registers the class, but the #more anchor is removed so that when you click on the link it just takes you to the permalink without scrolling. I’ve tried adding ?> after with no luck. I have my reading setting as “full text” and not “summary” so I’m not using the_excerpt.

    Any idea what I’m doing wrong here? Thank you in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • anonymized-13749270

    (@anonymized-13749270)

    #more wont work without a dash ‘-‘ followed by post ID.
    therefore add this : -<?php echo the_ID(); ?> like the following:

    add_filter( 'the_content_more_link', 'modify_read_more_link' );
    function modify_read_more_link() {
    return '<a class="more-link" href="' . get_permalink() . '#more-<?php echo the_ID(); ?>">Your Read More Link Text</a>';
    }

    tell me if it worked 😉

    Thread Starter whitesea

    (@whitesea)

    Hi sam elh,

    Unfortunately that didn’t work 🙁

    There are really no obvious solutions to this? I’m baffled.

    anonymized-13749270

    (@anonymized-13749270)

    hello whitesea,
    you can either create a child theme, then content.php and locate “read more” from your actual code then, replace it entirely with this :

    <?php echo '<a class="more-link" href="';
      the_permalink();
      echo '#more-';
      echo the_ID();
      echo '">';
      echo 'Continue Reading (or whatever text you want)';
      echo '</a>';
    ?>

    and then set your CSS rule ( .read-more ) and style the way you want.

    again, please go child theming or backing up your files..

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Customizing "read more"…anchor not working?’ is closed to new replies.