#60153 closed enhancement (duplicate)
Add filters to `get_template_part()`
| Reported by: | revxx14 | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Themes | Version: | 6.4.2 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
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.
Change History (3)
#2
in reply to: ↑ 1
@
3 years ago
- Resolution → duplicate
- Status new → closed
Replying to SergeyBiryukov:
Hi there, welcome back to WordPress Trac! Thanks for the ticket.
Since
get_template_part()useslocate_template()internally, it seems that this would be covered by #13239.
Also related: #42855.
Aha, you're right, I'll track that instead, thanks!
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Hi there, welcome back to WordPress Trac! Thanks for the ticket.
Since
get_template_part()useslocate_template()internally, it seems that this would be covered by #13239.Also related: #42855.