Hi how can we remove […] from excerpts?
thanks in advance
Hi pixallus!
Please add following code to Functions.php file in Appearance > Editor
function change_excerpt($text)
{
return rtrim($text,'[...]');
}
add_filter('get_the_excerpt', 'change_excerpt');
Regards,
Yigit
added to child theme functions.php and now its displays :
[&hellip
Hi!
Can you please change the code to following one
function change_excerpt($text)
{
return rtrim($text,'');
}
add_filter('get_the_excerpt', 'change_excerpt');
Best regards,
Yigit
now it’s back to: […]
Hi!
Thank you for coming back.
Replace the code above with the following:
function change_excerpt( $text )
{
$pos = strrpos( $text, '[');
if ($pos === false)
{
return $text;
}
return rtrim (substr($text, 0, $pos) );
}
add_filter('get_the_excerpt', 'change_excerpt');
Best regards,
Günter
this worked fine. thank guys!
how can we keep the … but remove only [ ] ?
Hey!
Use the following code:
function change_excerpt( $text )
{
$pos = strrpos( $text, '[');
if ($pos === false)
{
return $text;
}
return rtrim (substr($text, 0, $pos) ) . '....';
}
add_filter('get_the_excerpt', 'change_excerpt');
Cheers!
Günter
excellent!
thanks again!