[wp-trac] [WordPress Trac] #21676: Pass a variable to get_template_part()
WordPress Trac
noreply at wordpress.org
Thu Jul 2 22:30:39 UTC 2020
#21676: Pass a variable to get_template_part()
-------------------------------------+-----------------------------
Reporter: sc0ttkclark | Owner: SergeyBiryukov
Type: enhancement | Status: reviewing
Priority: normal | Milestone: 5.5
Component: Template | Version:
Severity: normal | Resolution:
Keywords: has-patch needs-testing | Focuses:
-------------------------------------+-----------------------------
Comment (by justlevine):
@johnbillion am I understanding the code wrong, because it looks to me
that $args needs to be passed explicitly. And if you're using your own
custom `global $args` in your foo.php template part, then that will still
overwrite what's passed, preserving back-compat.
Meaning:
{{{#!php
<?php
//foo.php
global $args;
echo $args[0];
}}}
{{{#!php
<?php
$args = [ 1, 2, 3 ];
get_template_part( 'foo'); // echoes 4.
get_template_part( 'foo', $args ); // still echoes 4.
}}}
at least that's the behavior i get when I apply the diff...
--
Ticket URL: <https://core.trac.wordpress.org/ticket/21676#comment:107>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list