Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#33859 closed enhancement (duplicate)

Custom variables in get_template_part

Reported by: sebastianpisula's profile sebastian.pisula Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.3
Component: Themes Keywords:
Focuses: Cc:

Description

For example:

get_template_part('page', 'part', array('username'=>'Sebastian'));

And in page-part.php

Hello, <?php echo $username;?>

Attachments (1)

custom-variables.patch (3.2 KB) - added by sebastian.pisula 9 years ago.

Download all attachments as: .zip

Change History (3)

#1 @nofearinc
9 years ago

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 extract is 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.

#2 @SergeyBiryukov
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #21676.

Note: See TracTickets for help on using tickets.