Skip to content

Commit

Permalink
Term Description block: Don't output if there's no description (#30564)
Browse files Browse the repository at this point in the history
* Term Description block: Don't output if there's no description
  • Loading branch information
carolinan authored Apr 9, 2021
1 parent 6fbbc98 commit 385d887
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/block-library/src/term-description/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@
*
* @param array $attributes Block attributes.
*
* @return string Returns the filtered post content of the current post.
* @return string Returns the description of the current taxonomy term, if available
*/
function render_block_core_term_description( $attributes ) {
$term_description = '';

if ( ! is_category() && ! is_tag() && ! is_tax() ) {
if ( is_category() || is_tag() || is_tax() ) {
$term_description = term_description();
}

if ( empty( $term_description ) ) {
return '';
}

Expand All @@ -23,7 +28,7 @@ function render_block_core_term_description( $attributes ) {
: array();
$wrapper_attributes = get_block_wrapper_attributes( $extra_attributes );

return '<div ' . $wrapper_attributes . '>' . term_description() . '</div>';
return '<div ' . $wrapper_attributes . '>' . $term_description . '</div>';
}

/**
Expand Down

0 comments on commit 385d887

Please sign in to comment.