Hi all. Great post!
I’m trying to get the excerpt made above to show tags. In other words, i want to show <a>
, <strong>
etc. in the excerpt. Any ideas on how to add that?
I tried this. Doesn’t work.
function custom_excerpt() {
global $post;
$text = get_field('innehall');
if ( '' != $text ) {
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$allowed_tags = '<p>,<a>,<em>,<strong>,<img>';
$text = strip_tags($text, $allowed_tags);
$text = str_replace(']]>', ']]>', $text);
$excerpt_length = 40; // 20 words
$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
}
return apply_filters('the_excerpt', $text);
}