Skip to content

Synced Patterns: Add slug field to user created patterns #50060

@goodpenguins

Description

@goodpenguins

What problem does this address?

This allows you to safely use reusable blocks in patterns.

The Real Challenge: More than 70 posts will use a set of blocks consisting of three static (headings and texts) and one dynamic block.

The easiest way to solve this problem is to create a pattern with synced pattern for static elements. It's convenient to store the generated pattern in the theme's "patterns" folder instead of including it in the theme's code.

The problem is that synced pattern blocks only have an id. In the HTML code of the pattern, they are called via ref={id}. But with a high probability in the development and production environments you will have different id of the same reused blocks. To solve the problem, one could set up different pattern folders depending on the environment variable ( WP_ENVIRONMENT_TYPE ). Unfortunately, I did not find a hook to change the path to the patterns folder.

What is your proposed solution?

Add a slug field to the reusable blocks and enable linking by this field (ref={slug}).

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Block] BlockThe "Reusable Block" Block[Block] PatternAffects the Patterns Block[Feature] PatternsA collection of blocks that can be synced (previously reusable blocks) or unsynced[Feature] Synced PatternsRelated to synced patterns (formerly reusable blocks)[Type] EnhancementA suggestion for improvement.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions