Skip to content

humanmade/post-link-block

Repository files navigation

HM Post Link Block

A block that wraps inner blocks in a link to the current post, for use in query loops.

Description

This plugin provides a single Post Link block that renders its inner blocks wrapped in a semantic <a> tag linking to the current post. It is designed to be used inside a Query Loop block, where it receives the current postId and postType from context.

Features

  • Wraps any inner blocks in a post permalink with semantic markup
  • Optional "open in new tab" setting (adds target="_blank" with rel="noopener noreferrer")
  • Supports color, spacing, and typography controls from the block editor
  • Compatible with client-side navigation in block themes

Installation

For Development

  1. Clone or download to /wp-content/plugins/post-link-block/
  2. Run npm install && npm run build
  3. Activate the plugin in WordPress

For Production

  1. Download a release bundle or clone the release branch
  2. Upload to /wp-content/plugins/post-link-block/
  3. Activate the plugin in WordPress

Usage

  1. Add a Query Loop block to your page
  2. Inside the Post Template, insert the Post Link block
  3. Add inner blocks inside Post Link — for example, Featured Image, Title, and Post Date
  4. On the front-end, the entire inner content is wrapped in a single link to the post

Screenshot of the block editor List View showing a Post Link block containing Featured Image, Title, and Post Date blocks, nested inside a Query Loop

Note: The block only renders a link when a postId is available from context. Outside a Query Loop it will fall back to get_the_ID(), but it is primarily intended for use within query loops.

Development

If you have nvm installed you can run nvm use in the repository root to activate the correct version of Node.

Setup

npm install
composer install

Build

npm run build

Development Mode

npm start

Linting

npm run lint

Requirements

  • WordPress 6.0+
  • PHP 8.2+
  • Node.js 24+

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 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:

  1. Review unreleased changes and choose the next version number using semantic versioning
  2. Checkout a prepare-v#.#.# branch. In that branch:
  3. Open a pull request titled "Prepare release v#.#.#"
  4. Review and merge the pull request
  5. Wait for the release branch to update with the build that includes the new version number
  6. On the "Tag and Release" GH Action page:
    • Click the "Run workflow" button
    • Fill out the "Version tag" field with your target version number
      • This version must match the version in post-link-block.php and block.json
      • Use the format v#.#.# for your version tag
    • Leave the "Branch to tag" field as release
    • Click "Run workflow"

Once the workflow completes, the new version will be tagged and available in the list of releases.

License

GPL-2.0-or-later

Author

Human Made Limited - https://humanmade.com

About

Provides a Post Link block to use in query loops

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors