WordPress.org

Ready to get started?Download WordPress

Forums

Excerpt Link (5 posts)

  1. darrenmtay
    Member
    Posted 1 year ago #

    Hi Guys,

    I have created a child theme based on the twentyten theme. It all works great however something strange is happening.

    The homepage displays a list of post excerts which is great. All of the links work great too.

    When i hover over the Post Title, the link displays correctly. When i hover over the 'Read More' link there seems to be an extra #more-' after the link. I have looked through all of the template files but am really struggling to see what is going on.

    When clicked it works fine but why is the read more link displaying this additional bit of code at the end of the link to the full post when i hover my mouse over it?

    Any help is hugely appreciated as ever guys.

    Thank you.

  2. Oliver Farrell
    Member
    Posted 1 year ago #

    By default WordPress will add the '#more-' after your posts permalinks. It enables people to skip to the rest of the article if they have read the excerpt.

    To remove that, you need to add the following to your functions.php

    function removeReadMoreHash($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', 'removeReadMoreHash');

    That should do the trick.

  3. dtay1984
    Member
    Posted 1 year ago #

    Hi Colin,

    Thanks for your help with this. Hugely appreciated. Doesnt seem to have any effect though. Here's the child theme functions.php file ...

    [538 lines of code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

  4. dtay1984
    Member
    Posted 1 year ago #

    Its near the top of the file. Sorry, i forgot to say.

  5. Oliver Farrell
    Member
    Posted 1 year ago #

    I noticed that you have two functions declared to remove the read more hash, maybe try deleting the second one.

    It's likely that there's some conflict with another function.

    Let me know whether removing the duplicate function works for you.

Topic Closed

This topic has been closed to new replies.

About this Topic