humanmade/hm-primary-category-block
Composer 安装命令:
composer require humanmade/hm-primary-category-block
包简介
Displays the primary category for a post.
README 文档
README
Displays the primary category for a post in the WordPress block editor.
Features
- Displays the primary category for a post
- Supports Yoast SEO primary category selection
- Server-side rendered for optimal performance
Usage
The Primary Category block is automatically available after plugin activation. The block uses the postId context and is typically used within:
- Query Loop blocks
- Post Templates
- Single post layouts
How it works
- The block automatically detects the post ID from context
- If Yoast SEO is active, it uses the primary category set by Yoast
- For posts with multiple categories, it returns the top-level parent category
- For single category posts, it returns that category
Block Name
The block is registered as hm/primary-category and can be inserted programmatically or used in block patterns.
Customization
The block outputs a link with the class hentry__category which can be styled via CSS:
.hentry__category { /* Your custom styles */ }
Installation
- Clone this repository to your WordPress plugins directory
- Run
npm installto install dependencies - Run
npm run buildto build the block - Activate the plugin in WordPress
Development
npm start- Start development mode with hot reloadnpm run build- Build production filesnpm run lint- Run linters
Requirements
- WordPress 6.0+
- PHP 8.2+
- Node.js 22+
Release Process
Merges to main will automatically build to the release branch. A project may be set up to track the release branch using composer to pull in the latest built beta version.
Commits on the release branch may be tagged for installation via packagist and marked as releases in GitHub for manual download using a manually-dispatched "Tag and Release" GH Actions workflow.
To tag a new release,
- Review the unreleased features in the Changelog and choose the target version number for the next release using semantic versioning
- Checkout a
prepare-v#.#.#branch. In that branch,- Add a new header into CHANGELOG.md for any unreleased features
- Bump the version number in the hm-primary-category-block.php file's PHPDoc header
- Open a pull request from your branch titled "Prepare release v#.#.#"
- Review and merge your "Prepare release" pull request
- Wait for the
releasebranch to update with the build that includes the new version number - On the "Tag and Release" GH Action page],
- Click the "Run workflow" button in the "workflow_dispatch" notification banner (see screenshot below)
- Fill out the "Version tag" field with your target version number
- This version must match the version in
hm-primary-category-block.phpand your newest Changelog section - Use the format
v#.#.#for your version tag
- This version must match the version in
- Leave the "Branch to tag" field as
release(we will add the tag on the release branch containing the latest built code) - Click "Run workflow"
Once the workflow completes, your new version should be tagged and available in the list of releases
License
GPL-2.0-or-later
humanmade/hm-primary-category-block 适用场景与选型建议
humanmade/hm-primary-category-block 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 humanmade/hm-primary-category-block 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 humanmade/hm-primary-category-block 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2026-02-23
