feat: add tag labels support to Content Loop block#2282
feat: add tag labels support to Content Loop block#2282jason10lee wants to merge 7 commits intotrunkfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for displaying selected tags as labels in the Content Loop block (Homepage Articles block). The feature allows tags to be designated as "labels" that appear above post headlines, with customizable text and colors.
Changes:
- Added backend methods to retrieve and format tag labels for posts
- Integrated tag labels into the REST API response for posts
- Updated the Content Loop block template and editor preview to display tag labels
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| includes/class-newspack-blocks.php | Added three new methods: get_tag_labels(), generate_tag_labels(), and display_tag_labels() to retrieve and render tag labels |
| includes/class-newspack-blocks-api.php | Added newspack_blocks_get_tag_labels() method and integrated tag labels into the posts REST API endpoint |
| src/blocks/homepage-articles/templates/article.php | Updated template to retrieve and display tag labels for each post |
| src/blocks/homepage-articles/edit.tsx | Added rendering logic for tag labels in the block editor preview |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Feature works well. A few inline notes, plus one scope suggestion: the Carousel block shares the same REST API data as Homepage Articles but does not render tag labels yet -- worth considering as a follow-up so the label experience is consistent across both content blocks.
|
Swapping the labels since this seems to need some additional work. |
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-theme#2613
See also: Automattic/newspack-plugin#4381
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:
Basic operation:
Multiple labels:
Custom label text (flag):
Custom label color:
Other information: