[wp-trac] [WordPress Trac] #62523: Can't register Block Templates for CPTs with an underscore "_" character in the key

WordPress Trac noreply at wordpress.org
Mon Dec 9 13:20:20 UTC 2024


#62523: Can't register Block Templates for CPTs with an underscore "_" character in
the key
-------------------------------------------------+-------------------------
 Reporter:  alexandrebuffet                      |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Editor                               |     Version:  6.7
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-testing has-         |     Focuses:  template
  testing-info                                   |
-------------------------------------------------+-------------------------

Comment (by gaambo):

 `register_post_type` uses `sanitize_key` to sanitize the post type key,
 which in turn uses the following regex pattern: `/[^a-z0-9_\-]/` I would
 recommend, to use the same regex and also comment/document that this must
 be the same as in register_post_type/sanitize_key so that it works for all
 post types.
 I don't think there should be any problems with file names, since the same
 works for existing .php templates in classic themes as well.

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


More information about the wp-trac mailing list