[wp-trac] [WordPress Trac] #60153: Add filters to `get_template_part()`

WordPress Trac noreply at wordpress.org
Tue Dec 26 15:50:08 UTC 2023


#60153: Add filters to `get_template_part()`
-------------------------+-------------------------------
 Reporter:  revxx14      |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Themes       |    Version:  6.4.2
 Severity:  normal       |   Keywords:  changes-requested
  Focuses:               |
-------------------------+-------------------------------
 I'm building a custom componentized framework for developing WordPress
 themes within my company. These components will be installed as composer
 libraries, and I'd like to include them like so...

 `get_template_part("company-name", "package-name", $args);`

 This would then be intercepted by a filter, to look in `/wp-content/themes
 /my-theme/vendor/company-name/package-name` for `template.php`.

 This seems like a relatively easy thing to achieve, but there are
 currently no filters provided in `get_template_part()`. I'd appreciate the
 ability to filter the final path, with read access to the input
 parameters.

 I can of course achieve this by wrapping `get_template_part()` in a helper
 function like `company_name_get_template_part()`, but I'd prefer the more
 elegant approach of filtering the function directory.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60153>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list