diff --git a/packages/block-library/src/post-terms/edit.js b/packages/block-library/src/post-terms/edit.js index 3532fb747f7592..2e950479a9bcf3 100644 --- a/packages/block-library/src/post-terms/edit.js +++ b/packages/block-library/src/post-terms/edit.js @@ -59,6 +59,7 @@ export default function PostTermsEdit( { const blockProps = useBlockProps( { className: classnames( { [ `has-text-align-${ textAlign }` ]: textAlign, + [ `taxonomy-${ term }` ]: term, } ), } ); diff --git a/packages/block-library/src/post-terms/index.php b/packages/block-library/src/post-terms/index.php index f5c4e5781e2a7e..0af8742f869b9f 100644 --- a/packages/block-library/src/post-terms/index.php +++ b/packages/block-library/src/post-terms/index.php @@ -26,7 +26,10 @@ function render_block_core_post_terms( $attributes, $content, $block ) { return ''; } - $align_class_name = empty( $attributes['textAlign'] ) ? '' : ' ' . "has-text-align-{$attributes['textAlign']}"; + $classes = 'taxonomy-' . $attributes['term']; + if ( isset( $attributes['textAlign'] ) ) { + $classes .= ' has-text-align-' . $attributes['textAlign']; + } $terms_links = ''; foreach ( $post_terms as $term ) { @@ -37,7 +40,7 @@ function render_block_core_post_terms( $attributes, $content, $block ) { ); } $terms_links = trim( $terms_links, ' | ' ); - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); return sprintf( '