[Resolved] Removing the #more anchor from post URLs

Home Forums Support Removing the #more anchor from post URLs

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #275399
    Dave Foy

    My problem: I’m trying to remove the #more anchor tag from my ‘Read more’ links on standard post archive pages, but I can’t make them disappear! The problem seems to be because I’m not using excerpts in this case. Instead I’m using the <!–more–> tag to display the ‘Read more’ button.

    This is the code in my child theme functions.php.

    function remove_more_link_scroll( $link ) {
    	$link = preg_replace( '|#more-[0-9]+|', '', $link );
    	return $link;
    }
    add_filter( 'the_content_more_link', 'remove_more_link_scroll' );

    I got it from the Codex.

    Example from a site still in development.

    This is just a standard/default WP posts page.

    Thanks for your help.

    PS: Reason I’m not using excerpts, if you’re interested…

    I have a few other posts listings on the site (e.g. 3 in a row on the home page), using Elementor’s Posts widget. These automatically pull in the featured image, which I need to be at a certain ratio best suited to the display on the home page.

    On the Blog listing page, I’m manually adding a fake ‘featured image’ at the top of posts, before the <!–more–> tag, at a better ratio suited to the Blog listing page – i.e. they’re not as tall as the actual real featured images, so they don’t use up as much vertical space on the listing page. If I use the same featured image that looks great on the home page, it looks too tall on the blog listing page.

    GeneratePress 1.3.44
    #275613
    Tom
    Lead Developer
    Lead Developer

    Hi Dave,

    There’s a GP filter for that.

    Take a look: https://docs.generatepress.com/article/generate_more_jump/

    Let me know if you need more info 🙂

    #275691
    Dave Foy

    I honestly did look!

    Thanks Tom. All sorted. Thanks!

    #275692
    Tom
    Lead Developer
    Lead Developer

    I added that filter to the docs this morning so I believe you! 🙂

    Thanks for the push 😉

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.