The What
Syntax
get_template_part( string $generic_template_name, string $specific_template_name = null );
Description
This construct fires the event get_template_part-{$generic_template_name}
and then locates the template to be loaded. If a specific template file name was supplied when calling this function, it will search for {$generic_template_name}-{$specific_template_name}.php
; else it searches for {$specific_template_name}.php
. If the template is found, then it’s loaded.
Parameters
generic_template_name
- The name of the generic template file you want to find and load. For example, to load the
welcome.php
template file, you would pass “welcome” to this parameter. specific_template_name
- optional The name of the specific (unique) portion of the template file you want to find and load. For example, to load
welcome-front.php
, you would pass “front” to this parameter. The default value isnull
.
Return Values
This function does not return anything.
Who needs copy/paste? Right. Writing code from scratch is fun!
More coming soon…keep checking back.