WordPress Outputting Excerpt as link not working correctly?

  • Unknown's avatar

    I need to output a custom ‘read more’ button for every post.

    I use the following function that I’ve made:

    function the_excerpt_more_link( $excerpt ){
    $post = get_post();
    $url = ‘https:/www.vierenzestig.nl/’;
    $postslug = $post->post_name;
    $link = $url . $postslug;
    $excerpt = ‘Lees meer!‘;

    return $link;
    }
    This is working as expected and it outputs the following :

    https:/www.vierenzestig.nl/interior-car-wash-and-detailing-service
    When I try to wrap the above output inside an element. It also displays the home url from the website. Using this code (see the replacement of $link with $excerpt):

    function the_excerpt_more_link( $excerpt ){
    $post = get_post();
    $url = ‘https:/www.vierenzestig.nl/’;
    $postslug = $post->post_name;
    $link = $url . $postslug;
    $excerpt = ‘Lees meer!‘;

    return $excerpt;
    }
    This outputs the following :

    An link with the text: ‘Lees Meer’. But the link is navigating to the following :

    Home

    Why is the same use of code resulting in a different output of code?

    The blog I need help with is: (visible only to logged in users)

  • Good Morning –

    I’m not experiencing that site redirect. Also, please understand that your site does not use the managed hosting environment from WordPresss.com. You will need to visit https://wordpress.org/support/forums/ to get assistance with that site.

  • The topic ‘WordPress Outputting Excerpt as link not working correctly?’ is closed to new replies.