Opened 11 years ago
Closed 11 years ago
#33859 closed enhancement (duplicate)
Custom variables in get_template_part
| Reported by: | sebastian.pisula | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Themes | Version: | 4.3 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
For example:
get_template_part('page', 'part', array('username'=>'Sebastian'));
And in page-part.php
Hello, <?php echo $username;?>
Attachments (1)
Change History (3)
Note:
See TracTickets
for help on using tickets.
I like the idea of being able to make template parts more dynamic without introducing global variables or perform numerous checks (including database calls in the "views").
However I don't think that
extractis a good idea though since it pollutes the current symbol table and could lead to various issues. It has been gradually removed from Core in #22400. Probably working with the $params array directly would do just fine.