get_template_part()
Syntax#
- get_template_part( $slug, $name );
- get_template_part( $slug );
Parameters#
| Parameter | Details |
|---|---|
| $slug | (string) Generic template slug name |
| $name | (string) Specialized template name |
| ## Load a template part from a subfolder |
get_template_part( 'foo/bar', 'page');will require ‘bar-page.php’ from the directory ‘foo’.
Get a specific file
You can get specific file using this function.
get_template_part('template-parts/layout');Include layout.php file from template-parts subdirectory placed in the root of your theme folder.