WordPressget_template_part()


Introduction

The purpose of this function is to standardize the way import partials or components of a theme into the main theme template. You could use a standard PHP SSI (server side includes), however, there are some benefits to using get_template_part(). Using this function reduces errors prone to less experienced developers trying to identify fully qualified path on the server.Also, it fails gracefully when files don't exist, and handles a custom hierarchy fallback system aka "fuzzy template searching".

Syntax

  • get_template_part( $slug )
  • get_template_part( $slug, $name )

Parameters

ParameterDetails
$slug(string) The slug name of the custom template.
$name(string) The name of the specialized template. Optional