Make WordPress Core

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)

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

Download all attachments as: .zip

Change History (3)

#1 @nofearinc
11 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
11 years ago

  • Milestone Awaiting Review
  • Resolution → duplicate
  • Status new → closed

Duplicate of #21676.

Note: See TracTickets for help on using tickets.