Skip to content

Commit

Permalink
Fixing the excerpt display #368
Browse files Browse the repository at this point in the history
  • Loading branch information
krugazul committed Jan 6, 2025
1 parent 90a8785 commit 923d209
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions includes/classes/legacy/class-destination.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,21 @@ public function travel_information_excerpt( $html = '', $meta_key = false, $valu
if ( get_post_type() === 'destination' && in_array( $meta_key, $ti_keys ) ) {
$this->modals[ $meta_key ] = $html;

$value = strip_tags( $html );
$value = wp_trim_excerpt( wp_strip_all_tags( $html ) );
$value = str_replace( '<br>', ' ', $value );
$value = str_replace( '<br />', ' ', $value );

if ( strlen( $value ) > $limit_chars ) {
$position = strpos( $value, ' ', $limit_chars );
$value_output = substr( $value, 0, $position );

if ( false !== $position ) {
$value_output = substr( $value, 0, $position );
} else {
$value_output = $value;
}
$value = trim( force_balance_tags( $value_output . '...' ) );
}

$value = trim( force_balance_tags( $value ) );
$html = apply_filters( 'the_content', $value );

$html = trim( force_balance_tags( $value ) );
}
return $html;
}
Expand Down

0 comments on commit 923d209

Please sign in to comment.