Excerpt functions is removing the forward slash on the url

Question

Excerpt functions is removing the forward slash on the url – I am completely lost here I can’t find a way to make it work.

I am very new on php programming any help would be very appreciated.

I am calling this function on my index.php

index.php :

<?php echo get_excerpt_max_charlength('260', true) ?>   



functions.php :


function get_excerpt_max_charlength($charlength, $readmore = true) {
$excerpt = get_the_excerpt();
$charlength++;

if ( mb_strlen( $excerpt ) > $charlength ) {
    $subex = mb_substr( $excerpt, 0, $charlength - 5 );
    $exwords = explode( ' ', $subex );
    $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
    if ( $excut < 0 ) {
        $str = mb_substr( $subex, 0, $excut );
    } else {
        $str = $subex;
    }
    return $readmore ? $str . '&hellip; <a href="' . get_permalink() . '">' . __('read more') . '</a>' : $str . '&hellip;';
} else {
    return $excerpt;
}
} 

Forward slash removed :

enter image description here

UPDATE I have found the fix – not bad for someone is new in programming.

 return $readmore ? $str . '<a class="more-link" href="'. get_permalink($post->ID) . '">'. __('read more') .'</a>' . '</a>' : $str . '&hellip;';
0
Nuno Sarmento 2 months 0 Answers 15 views 0

Leave an answer