Remove anchor link from More links

Community Forums Forums Design Tips and Tricks Remove anchor link from More links

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  rfmeier 10 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #46895

    Gradient
    Participant
    Post count: 32

    Hi,

    I’m using the More tag on content I display in the Genesis responsive slider. When you click on the “Continue Reading” link, it takes you to the place where the read more link starts from. I would prefer it just to go to the full page, and not the anchor link of the more tag.

    I think there is a plugin I can use to change this behaviour, but was hoping a bit of code tweaking would also do the trick.

    Example more anchor link

    Any suggestions?

    Thanks,

    Kier.

    • This topic was modified 10 months ago by  Gradient.
    • This topic was modified 10 months ago by  Gradient.
    • This topic was modified 10 months ago by  Gradient.
    • This topic was modified 10 months ago by  Gradient.
    • This topic was modified 10 months ago by  Gradient.
    • This topic was modified 10 months ago by  Gradient.
    http://www.callevanetworks.com/take-control-ip-address/#more-418
    #46904

    rfmeier
    Participant
    Post count: 517

    Hello,

    Try the code below in your functions.php file.

    add_filter( 'the_content_more_link', 'custom_the_content_more_link', 10, 2 );
    /**
     * Callback for WordPress 'the_content_more_link' filter.
     * 
     * Remove hash id within more link url.
     * 
     * @param string $more_link the link html element
     * @param string $more_link_text the more link text
     * @return string $more_link the link html element
     */
    function custom_the_content_more_link( $more_link, $more_link_text ){
    	
    	// return custom link without hash id
    	return sprintf( '<a href="%s" class="more-link">%s</a>', get_permalink(), esc_html( $more_link_text ) );
    	
    }

    I wasn’t able to fully test it, but it is just a modified core version.

    Hope this helps.


    Ryan Meier – Web Developer @ Solid Interactive
    Twitter

    #46911

    Gradient
    Participant
    Post count: 32

    Hi Ryan,

    Works perfect ! Thanks, appreciate your help.

    -Kier.

    #46914

    rfmeier
    Participant
    Post count: 517

    You are welcome. I am glad I could help.


    Ryan Meier – Web Developer @ Solid Interactive
    Twitter

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.