Skip to content

Commit

Permalink
Post Terms: Fix fatal error when 'get_the_term_list' returns 'WP_Erro…
Browse files Browse the repository at this point in the history
…r' (#65848)


Co-authored-by: up1512001 <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: david-binda <[email protected]>
  • Loading branch information
4 people authored Oct 3, 2024
1 parent f4402db commit 46fdb67
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/block-library/src/post-terms/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,19 @@ function render_block_core_post_terms( $attributes, $content, $block ) {
$suffix = '<span class="wp-block-post-terms__suffix">' . $attributes['suffix'] . '</span>' . $suffix;
}

return get_the_term_list(
$post_terms = get_the_term_list(
$block->context['postId'],
$attributes['term'],
wp_kses_post( $prefix ),
'<span class="wp-block-post-terms__separator">' . esc_html( $separator ) . '</span>',
wp_kses_post( $suffix )
);

if ( is_wp_error( $post_terms ) ) {
return '';
}

return $post_terms;
}

/**
Expand Down

0 comments on commit 46fdb67

Please sign in to comment.