feat: add support for tag labels#2613
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds support for displaying selected tags as labels on posts in the Newspack theme. Tag labels appear before headlines in non-singular contexts (like archive pages) and alongside category labels in singular contexts (individual post pages). The feature integrates with the corresponding newspack-plugin implementation and includes graceful degradation when the plugin is not available.
Key changes:
- Added tag label display logic to template files for singular and archive views
- Created new SCSS styling for tag labels with responsive design considerations
- Implemented PHP shim functions to integrate with the newspack-plugin Tag_Labels class
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/compile-scss.js | Added compilation entry for the new newspack-tag-labels.scss stylesheet |
| newspack-theme/template-parts/header/entry-header.php | Integrated tag label display in post headers for singular views |
| newspack-theme/template-parts/content/content-excerpt.php | Added tag labels to post excerpts in archive contexts |
| newspack-theme/template-parts/content/content-archive.php | Added tag labels to archived content displays |
| newspack-theme/sass/plugins/newspack-tag-labels.scss | Created stylesheet with tag label styling for various contexts |
| newspack-theme/inc/newspack-tag-labels.php | Implemented shim functions for tag label generation, display, and styling |
| newspack-theme/functions.php | Added phpcs ignore directives and loaded tag labels compatibility file |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Thanks, @thomasguillot! That makes a lot of sense, and your and @laurelfulford's suggestion on using a contrast color for the text color would complement that perfectly. I'll work up those changes for these tag labels.
What are your thoughts on the positioning of this label? Should we put it on the same line as (say) the |
I'd say same line as the SPONSORED label. It's unlikely a publisher will have a sponsored label AND a tag label. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Heads-up--PHPCS is snippy and |
dkoo
left a comment
There was a problem hiding this comment.
Almost there! I'm still seeing a lack of padding for the tag label when displayed in a Content Loop block, as screenshotted earlier. All other areas seem to be styled correctly.
wil-gerken
left a comment
There was a problem hiding this comment.
I tested the full feature end-to-end on a live env with all three feat/tag-labels branches, and it's looking great. I also verified each previous comment thread, and they all look resolved (except one-ish): the custom color doesn't apply on single-post and archive pages. I think this one needs to be addressed before merge.
Prior review threads (shared status):
| Thread | Status |
|---|---|
| @dkoo — padding lost in the Content Loop block | ✅ Fixed — non-zero padding confirmed on home, archive, and single. The changes-requested review appears to predate the 5/27 specificity fix. |
@adekbadek — newspack_generate_tag_labels / display duplicate the plugin's methods |
✅ Fixed — both now delegate to \Newspack\Tag_Labels. |
@thomasguillot — label font-size inheriting the h2 |
✅ Fixed — the label renders outside the title at the expected size. |
| @thomasguillot — label color tied to the sponsor highlight |
Once the color override is fixed, this should be ready to merge. @dkoo may also want to re-review the padding thread, since that request now appears satisfied.
|
Thanks, @wil-gerken ! Please have another look when you get a chance. |
wil-gerken
left a comment
There was a problem hiding this comment.
Thanks Jason! I re-tested the new commits on a live env. The custom-color fix holds in all three contexts now: home, archive, and single all honor a custom color (single/archive were falling back to the highlight color before). Padding's intact and the markup-order CSS round looks great. Thanks for the quick turnaround!
Note: The PR still shows changes requested in Derrick's earlier padding review, which has also been fixed. I think @dkoo will need to re-review to clear the block.
|
Hey @jason10lee, good job getting this PR merged! 🎉 Now, the Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label. If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label. Thank you! ❤️ |

All Submissions:
Changes proposed in this Pull Request:
This PR is one of a set that adds the ability to display selected tags as labels. Changes live in the
feat/tag-labelstopic branch on the newspack-blocks, newspack-plugin, and newspack-theme projects.See also: Automattic/newspack-plugin#4381
See also: Automattic/newspack-blocks#2282
In non-singular context (as part of a Content Loop block, for example), the tag label will show up in front of the headline.In singular context (on the individual post page, for example), the tag label will show up with the category label.By default, the text of the tag label will be the same as the tag name. Optionally, the label text can be customized (e.g., to something shorter and more suitable for use as a label).Labels will appear above the headline, after any category or sponsorship labels.
By default, the text of the tag label will be the same as the tag name. Optionally, the label text can be customized (e.g., to something shorter and more suitable for use as a label). Additionally, the label color can be customized in the Newspack Theme customizer.
Addresses NPPD-383: "Breaking News" or "Developing" Label.
How to test the changes in this Pull Request:
These instructions will be pretty much identical between these two PRs--if you've tested one, you've tested the other.
Basic operation:
Multiple labels:
Custom label text (flag):
Custom label color:
Other information: