Skip to content
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

Block Pattern category Duplicates term with different slug #69078

Open
3 of 6 tasks
jigneshnakrani088 opened this issue Feb 6, 2025 · 2 comments
Open
3 of 6 tasks

Block Pattern category Duplicates term with different slug #69078

jigneshnakrani088 opened this issue Feb 6, 2025 · 2 comments
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Type] Bug An existing feature does not function as intended

Comments

@jigneshnakrani088
Copy link

Description

When registering a new pattern category with / as per Developer Docs, i.e themeslug/custom and when I select "Add new pattern" and select the category from the list, the slug is themeslug-custom which is a new category(duplicate) with same Name.

This has been reported in Trac Ticket; as per suggestion reporting the issue here.

Step-by-step reproduction instructions

  1. Register a block pattern category and pattern as per docs,
add_action( 'init', 'themeslug_register_pattern_categories' );

function themeslug_register_pattern_categories() {
	register_block_pattern_category( 'themeslug/custom', array( 
		'label'       => __( 'Theme Name: Custom', 'themeslug' ),
		'description' => __( 'Custom patterns for Theme Name.', 'themeslug' )
	) );
}

Now try adding the themeslug/custom category to any block pattern:

<?php
/**
 * Title: Hero
 * Slug: themeslug/hero
 * Categories: featured, themeslug/custom
 */
?>
<!-- Your block markup goes here. -->
  1. Go to Appearance > Editor > Patterns and select the specific pattern (the slug is themeslug%2Fcustom)
  2. Select "Add new pattern" or Duplicate any existing pattern
  3. And select Theme Name: Custom category from the list,
    • The pattern will have a new category assigned and the slug will be themeslug-custom
    • Will have two categories with the same name but with different slugs.

Screenshots, screen recording, code snippet

Image

Environment info

  • WordPress: 6.8-alpha
  • Theme: Twenty Twenty-Four

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@jigneshnakrani088 jigneshnakrani088 added the [Type] Bug An existing feature does not function as intended label Feb 6, 2025
@Mamaduka Mamaduka added the [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced label Feb 6, 2025
@Andrew-Starr
Copy link

I've always used themeslug_custom and have not seen the duplicate issue doing it this way.

So now wondering if the reference in the docs incorrect or is there an issue in the pattern registry class?

@jigneshnakrani088
Copy link
Author

themeslug_custom and have not seen the duplicate issue doing it this way.

Correct, it will not create any duplications there.

So now wondering if the reference in the docs incorrect or is there an issue in the pattern registry class?

On second thought, it's the issue with the example in the docs reference. and I already raised the issue there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants