From 46fdb6719d771e8886ac321a504b5bac21ee4b36 Mon Sep 17 00:00:00 2001 From: Utsav Patel <75293077+up1512001@users.noreply.github.com> Date: Thu, 3 Oct 2024 23:12:50 +0530 Subject: [PATCH] Post Terms: Fix fatal error when 'get_the_term_list' returns 'WP_Error' (#65848) Co-authored-by: up1512001 Co-authored-by: Mamaduka Co-authored-by: david-binda --- packages/block-library/src/post-terms/index.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/post-terms/index.php b/packages/block-library/src/post-terms/index.php index 69d7b04b096b53..60ffdcedf3268f 100644 --- a/packages/block-library/src/post-terms/index.php +++ b/packages/block-library/src/post-terms/index.php @@ -51,13 +51,19 @@ function render_block_core_post_terms( $attributes, $content, $block ) { $suffix = '' . $attributes['suffix'] . '' . $suffix; } - return get_the_term_list( + $post_terms = get_the_term_list( $block->context['postId'], $attributes['term'], wp_kses_post( $prefix ), '' . esc_html( $separator ) . '', wp_kses_post( $suffix ) ); + + if ( is_wp_error( $post_terms ) ) { + return ''; + } + + return $post_terms; } /**