Replies: 0
Hello, how could I make this function conditional to only run on the front end if the page isn’t using Gutenberg?
I just wanted to allow some html tags in get_the_excerpt on the archive pages.
But this doesn’t work with AB Post Grid Block.
So,
function excerpt_allow_markup($text) {
global $post;
if ( '' == $text ) {
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace('\]\]\>', ']]>', $text);
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
$text = strip_tags($text, '<img>','<p>','<em>','<strong>','<h3>');
$excerpt_length = 80;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words)> $excerpt_length) {
array_pop($words);
array_push($words, '[...]');
$text = implode(' ', $words);
}
}
return $text;
}
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'excerpt_allow_markup');
If I ask
if( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) {
It tells me
Call to undefined function get_current_screen()
I guess this function must be intended for the back end?
I thought if(is_archive()) should work too, but apparently not for this block.