[wp-trac] [WordPress Trac] #62378: Allow patterns files to be divided into sub folders inside the main "patterns" folder

WordPress Trac noreply at wordpress.org
Mon Mar 31 09:39:29 UTC 2025


#62378: Allow patterns files to be divided into sub folders inside the main
"patterns" folder
------------------------------+------------------------
 Reporter:  juanfra           |       Owner:  joemcgill
     Type:  enhancement       |      Status:  closed
 Priority:  normal            |   Milestone:  6.8
Component:  Themes            |     Version:
 Severity:  normal            |  Resolution:  fixed
 Keywords:  has-patch commit  |     Focuses:
------------------------------+------------------------

Comment (by webmandesign):

 Hi,

 Since testing WP6.8 RC1 I get this PHP notice:

 {{{
 Notice:
 Function get_block_patterns was called incorrectly.
 Could not register file "./themes/theme-slug/patterns/affected/file.php"
 as a block pattern ("Slug" field missing)
 Please see Debugging in WordPress for more information.
 (This message was added in version 6.0.0.) in ./wp-includes/functions.php
 on line 6121
 }}}

 Could you please modify the code to ''**skip all PHP files without "Slug"
 defined**'' in `theme-slug/patterns` folder?

 As maybe that file is not a pattern registration file on purpose.
 That way the notice is not triggered.

 ----

 **My usecase for explanation:**

 In my theme I register most of the patterns with proper file metadata.

 However, one of the patterns runs dynamic PHP code that has to be
 registered later on front-end (during `wp` action hook) to receive proper
 data from WordPress. I need to register this pattern using PHP
 [https://developer.wordpress.org/reference/functions/register_block_pattern/
 `register_block_pattern()` function] instead of setting the pattern file
 metadata.

 To fix the new WP6.8 PHP notice I would need to move the affected pattern
 from `patterns/` folder to other folder, such as `patterns-other/`, which
 creates inconsistency in my theme code organization.

 Another alternative solution for me would be to register all patterns with
 `register_block_pattern()` function and not use `patterns/` folder at
 all...

 Pre-WP6.8 solution was to have pattern files with metadata as direct
 children of `patterns/` folder and use subfolders for the patterns
 registered via `register_block_pattern()` function.

 ----

 Please let me know if this is the correct place to ask for this or whether
 I should log a new ticket for this improvement to be included in WP6.8
 release. Thank you.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62378#comment:23>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list