From de752805bbb98fc38adfe322d6e07bfab1531ae9 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Wed, 24 Jun 2026 18:04:08 -0700 Subject: [PATCH 1/4] feat: add tag labels support to Carousel block Co-Authored-By: Claude Opus 4.8 --- .../src/blocks/carousel/block.json | 4 ++++ .../src/blocks/carousel/edit.js | 21 +++++++++++++++++++ .../src/blocks/carousel/view.php | 14 ++++++++++++- .../inc/newspack-tag-labels.php | 1 + 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/plugins/newspack-blocks/src/blocks/carousel/block.json b/plugins/newspack-blocks/src/blocks/carousel/block.json index 26cfc2a3c9..2821aa6ef9 100644 --- a/plugins/newspack-blocks/src/blocks/carousel/block.json +++ b/plugins/newspack-blocks/src/blocks/carousel/block.json @@ -72,6 +72,10 @@ "type": "boolean", "default": false }, + "showTagLabels": { + "type": "boolean", + "default": true + }, "showTitle": { "type": "boolean", "default": true diff --git a/plugins/newspack-blocks/src/blocks/carousel/edit.js b/plugins/newspack-blocks/src/blocks/carousel/edit.js index 4b7ed93613..520409ad85 100644 --- a/plugins/newspack-blocks/src/blocks/carousel/edit.js +++ b/plugins/newspack-blocks/src/blocks/carousel/edit.js @@ -148,6 +148,7 @@ class Edit extends Component { postsToShow, postType, showCategory, + showTagLabels, showDate, showAuthor, showAvatar, @@ -334,6 +335,11 @@ class Edit extends Component { checked={ showCategory } onChange={ () => setAttributes( { showCategory: ! showCategory } ) } /> + setAttributes( { showTagLabels: ! showTagLabels } ) } + /> ) } + { showTagLabels && post.newspack_tag_labels && ( +
+ { post.newspack_tag_labels.map( ( newspack_tag_label, index ) => { + return newspack_tag_label.link ? ( + + { newspack_tag_label.flag } + + ) : ( + + { newspack_tag_label.flag } + + ); + } ) } +
+ ) } { showTitle && (

{ decodeEntities( post.title.rendered.trim() ) } diff --git a/plugins/newspack-blocks/src/blocks/carousel/view.php b/plugins/newspack-blocks/src/blocks/carousel/view.php index 5e57a115d7..b99060ca0f 100644 --- a/plugins/newspack-blocks/src/blocks/carousel/view.php +++ b/plugins/newspack-blocks/src/blocks/carousel/view.php @@ -66,6 +66,10 @@ function newspack_blocks_render_block_carousel( $attributes ) { // Get sponsors for this post. $sponsors = Newspack_Blocks::get_all_sponsors( $post_id ); + // Get tag labels for this post, but only when the block is set to show them + // (avoids a per-post taxonomy lookup when tag labels are disabled). + $tag_labels = ( $attributes['showTagLabels'] ?? true ) ? Newspack_Blocks::get_tag_labels( $post_id ) : null; + $counter++; $has_featured_image = has_post_thumbnail(); $post_type = get_post_type(); @@ -110,7 +114,7 @@ function newspack_blocks_render_block_carousel( $attributes ) { - +

' ); } @@ -382,6 +390,10 @@ function newspack_blocks_register_carousel() { 'type' => 'boolean', 'default' => false, ), + 'showTagLabels' => array( + 'type' => 'boolean', + 'default' => true, + ), 'showDate' => array( 'type' => 'boolean', 'default' => true, diff --git a/themes/newspack-theme/newspack-theme/inc/newspack-tag-labels.php b/themes/newspack-theme/newspack-theme/inc/newspack-tag-labels.php index 8c713a5b06..1f4dfa77c8 100644 --- a/themes/newspack-theme/newspack-theme/inc/newspack-tag-labels.php +++ b/themes/newspack-theme/newspack-theme/inc/newspack-tag-labels.php @@ -147,6 +147,7 @@ function newspack_tag_labels_styles() { .tag-labels .tag-label.flag, amp-script .tag-labels .tag-label.flag, .wpnbha .tag-labels a.flag, + .wpnbpc .tag-labels a.flag, .featured-image-behind .tag-labels a.flag { background: ; color: ; From c00f62bc46025ba7d61d38d78b83075055f9923f Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Thu, 25 Jun 2026 12:34:33 -0700 Subject: [PATCH 2/4] fix: render tag labels after category on the same line Co-Authored-By: Claude Opus 4.8 --- .../sass/plugins/newspack-tag-labels.scss | 44 ++++++++++++------- .../template-parts/header/entry-header.php | 8 ++-- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/themes/newspack-theme/newspack-theme/sass/plugins/newspack-tag-labels.scss b/themes/newspack-theme/newspack-theme/sass/plugins/newspack-tag-labels.scss index 4ea962456f..644c8759ea 100644 --- a/themes/newspack-theme/newspack-theme/sass/plugins/newspack-tag-labels.scss +++ b/themes/newspack-theme/newspack-theme/sass/plugins/newspack-tag-labels.scss @@ -36,18 +36,39 @@ amp-script .tag-labels { } /* stylelint-enable */ +// Tag labels render after the category / sponsor label and sit on the same line, +// mirroring the sponsor → category convention. The category (or sponsor) `.cat-links` +// is immediately followed by the tag-labels `.cat-links.tag-labels` in every context +// (single posts, home, archive, search, and the Content Loop / Carousel blocks), so +// keep the preceding label inline-block and space the tag labels that follow it. +.cat-links:has( + .tag-labels ) { + display: inline-block; +} +.cat-links + .tag-labels { + display: inline-flex; + margin-left: 0.5em; +} + +// In the Content Loop (`.wpnbha`) and Carousel (`.wpnbpc`) blocks, `.cat-links` is set +// to `display: flex` (block-level), which would stack the category and the tag labels +// that follow it. Re-assert `inline-flex` with higher specificity so the category and +// tag labels share one line, matching single posts and the sponsor convention. +.wpnbha, +.wpnbpc { + .cat-links:has( + .tag-labels ), + .cat-links + .tag-labels { + display: inline-flex; + } + .cat-links + .tag-labels { + margin-left: 0.5em; + } +} + /* Single Posts */ .single { - // When categories are visible .tag-labels { display: inline-flex; } - // Labels render before categories (matching the sponsor-label convention), - // so space the category that follows a label — mirrors `.sponsor-label + .cat-links`. - .tag-labels + .cat-links { - display: inline-block; - margin-left: 0.5em; - } // Workaround margin/padding override for featured images. .featured-image-behind { @@ -76,18 +97,9 @@ amp-script .tag-labels { } } -// Re-show the category that follows a tag label on search results. -.search article .tag-labels + .cat-links { - display: inline-flex; -} - // Home page. .home { article { - .tag-labels, - .tag-labels + .cat-links { - display: inline-flex; - } .tag-labels a, .tag-labels a:hover { padding: 0.3em 0.5em; diff --git a/themes/newspack-theme/newspack-theme/template-parts/header/entry-header.php b/themes/newspack-theme/newspack-theme/template-parts/header/entry-header.php index 8fbc08a8b4..45094dbd4e 100755 --- a/themes/newspack-theme/newspack-theme/template-parts/header/entry-header.php +++ b/themes/newspack-theme/newspack-theme/template-parts/header/entry-header.php @@ -32,17 +32,17 @@ if ( ! is_page() ) : if ( ! empty( $native_sponsors ) ) { newspack_sponsor_label( $native_sponsors, null, true ); - if ( $tag_labels ) { - newspack_display_tag_labels( $tag_labels ); - } if ( $display_sponsors_and_categories ) { newspack_categories(); } - } else { if ( $tag_labels ) { newspack_display_tag_labels( $tag_labels ); } + } else { newspack_categories(); + if ( $tag_labels ) { + newspack_display_tag_labels( $tag_labels ); + } } endif; ?> From fb59a93d65a5c70b00dfeacacf8e60d85ce92ff3 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Thu, 25 Jun 2026 13:42:34 -0700 Subject: [PATCH 3/4] fix: order tag labels after category in archive, search, and editor Co-Authored-By: Claude Opus 4.8 --- .../plugins/newspack-tag-labels-editor.scss | 9 +++++-- .../sass/plugins/newspack-tag-labels.scss | 25 +++++++++++-------- .../content/content-archive.php | 8 +++--- .../content/content-excerpt.php | 8 +++--- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/themes/newspack-theme/newspack-theme/sass/plugins/newspack-tag-labels-editor.scss b/themes/newspack-theme/newspack-theme/sass/plugins/newspack-tag-labels-editor.scss index f14de75462..97d8b777fe 100644 --- a/themes/newspack-theme/newspack-theme/sass/plugins/newspack-tag-labels-editor.scss +++ b/themes/newspack-theme/newspack-theme/sass/plugins/newspack-tag-labels-editor.scss @@ -16,10 +16,15 @@ .block-editor { article { - .tag-labels, - .tag-labels + .cat-links { + // Tag labels follow the category on the same line (category → tag), matching the + // front-end order. + .cat-links:not( .sponsor-label ):has( + .tag-labels ), + .tag-labels { display: inline-flex; } + .cat-links + .tag-labels { + margin-left: 0.5em; + } .tag-label + .tag-label { margin-left: 0.3em; // Don't collapse multiple labels. } diff --git a/themes/newspack-theme/newspack-theme/sass/plugins/newspack-tag-labels.scss b/themes/newspack-theme/newspack-theme/sass/plugins/newspack-tag-labels.scss index 644c8759ea..24176fd993 100644 --- a/themes/newspack-theme/newspack-theme/sass/plugins/newspack-tag-labels.scss +++ b/themes/newspack-theme/newspack-theme/sass/plugins/newspack-tag-labels.scss @@ -36,12 +36,13 @@ amp-script .tag-labels { } /* stylelint-enable */ -// Tag labels render after the category / sponsor label and sit on the same line, -// mirroring the sponsor → category convention. The category (or sponsor) `.cat-links` -// is immediately followed by the tag-labels `.cat-links.tag-labels` in every context -// (single posts, home, archive, search, and the Content Loop / Carousel blocks), so -// keep the preceding label inline-block and space the tag labels that follow it. -.cat-links:has( + .tag-labels ) { +// Tag labels render after the category (and sponsor) label and sit on the same line, +// mirroring the sponsor → category convention. The category `.cat-links` is immediately +// followed by the tag-labels `.cat-links.tag-labels` in every context (single posts, +// home, archive, search, and the Content Loop / Carousel blocks), so keep it inline-block +// and space the tag labels that follow it. The sponsor `.cat-links.sponsor-label` keeps +// its own layout (from newspack-sponsors), so it is excluded here. +.cat-links:not( .sponsor-label ):has( + .tag-labels ) { display: inline-block; } .cat-links + .tag-labels { @@ -49,13 +50,15 @@ amp-script .tag-labels { margin-left: 0.5em; } -// In the Content Loop (`.wpnbha`) and Carousel (`.wpnbpc`) blocks, `.cat-links` is set -// to `display: flex` (block-level), which would stack the category and the tag labels -// that follow it. Re-assert `inline-flex` with higher specificity so the category and -// tag labels share one line, matching single posts and the sponsor convention. +// In the Content Loop (`.wpnbha`) and Carousel (`.wpnbpc`) blocks the category +// `.cat-links` is block-level (`display: flex` in `.wpnbha`, default block in `.wpnbpc`), +// which would stack the category and the tag labels that follow it. Re-assert +// `inline-flex` with higher specificity so the category and tag labels share one line. +// Sponsor rows (`.cat-links.sponsor-label`) are excluded so their own `flex`/`gap` +// layout wins deterministically. .wpnbha, .wpnbpc { - .cat-links:has( + .tag-labels ), + .cat-links:not( .sponsor-label ):has( + .tag-labels ), .cat-links + .tag-labels { display: inline-flex; } diff --git a/themes/newspack-theme/newspack-theme/template-parts/content/content-archive.php b/themes/newspack-theme/newspack-theme/template-parts/content/content-archive.php index af97203957..99803504c4 100644 --- a/themes/newspack-theme/newspack-theme/template-parts/content/content-archive.php +++ b/themes/newspack-theme/newspack-theme/template-parts/content/content-archive.php @@ -28,17 +28,17 @@ if ( ! empty( $native_sponsors ) ) { // Get label for native post sponsors. newspack_sponsor_label( $native_sponsors ); - if ( $tag_labels ) { - newspack_display_tag_labels( $tag_labels ); - } if ( $display_sponsors_and_categories ) { newspack_categories(); } - } else { if ( $tag_labels ) { newspack_display_tag_labels( $tag_labels ); } + } else { newspack_categories(); + if ( $tag_labels ) { + newspack_display_tag_labels( $tag_labels ); + } } } ?> diff --git a/themes/newspack-theme/newspack-theme/template-parts/content/content-excerpt.php b/themes/newspack-theme/newspack-theme/template-parts/content/content-excerpt.php index 149ca38ee1..a0c38789c2 100755 --- a/themes/newspack-theme/newspack-theme/template-parts/content/content-excerpt.php +++ b/themes/newspack-theme/newspack-theme/template-parts/content/content-excerpt.php @@ -28,17 +28,17 @@ if ( ! empty( $native_sponsors ) ) { // Get label for native post sponsors. newspack_sponsor_label( $native_sponsors ); - if ( $tag_labels ) { - newspack_display_tag_labels( $tag_labels ); - } if ( $display_sponsors_and_categories ) { newspack_categories(); } - } else { if ( $tag_labels ) { newspack_display_tag_labels( $tag_labels ); } + } else { newspack_categories(); + if ( $tag_labels ) { + newspack_display_tag_labels( $tag_labels ); + } } } ?> From 5705474d14e66c95c293846b658589a655e3ab13 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 30 Jun 2026 16:39:34 -0700 Subject: [PATCH 4/4] fix(carousel): include tag labels in editor wrapper gate Co-Authored-By: Claude Opus 4.8 (1M context) --- plugins/newspack-blocks/src/blocks/carousel/edit.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/newspack-blocks/src/blocks/carousel/edit.js b/plugins/newspack-blocks/src/blocks/carousel/edit.js index 520409ad85..cdfce326be 100644 --- a/plugins/newspack-blocks/src/blocks/carousel/edit.js +++ b/plugins/newspack-blocks/src/blocks/carousel/edit.js @@ -394,6 +394,7 @@ class Edit extends Component { { ( post.newspack_post_sponsors || showCategory || + ( showTagLabels && post.newspack_tag_labels ) || showTitle || showAuthor || showDate ||