-
Notifications
You must be signed in to change notification settings - Fork 67
feat: add support for tag labels #2613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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. |

All Submissions:
Changes proposed in this Pull Request:
This PR is one of a pair that adds the ability to display selected tags as labels. Changes live in the
feat/tag-labelstopic branch on the newspack-plugin and newspack-theme projects.See also: Automattic/newspack-plugin#4381
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).
Addresses NPPD-383: "Breaking News" or "Developing" Label.
Open questions:
phpcs:ignoredirectives with explanatory comments elsewhere.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):
Extra credit--plugin mismatch:
trunk.feat/tag-labelstopic branch.trunk.Other information: