Home » Docs » Functions » Template Functions » conductor_get_template_part()

Description

This function is a helper function which loads a Conductor template part based on parameters. Alternatively extra parameters (data), and WordPress global variables can be passed to the template part (see examples below).

Conductor will look in the active theme’s Conductor template path directory first. If a template part is found in the active theme, it will be loaded. Otherwise, the “fallback” (default) template part will be used if it exists (in the /conductor/templates/ directory).

Prior to the template part being loaded, the template name is passed to the conductor_get_template_part filter.

Note: If a template is not found, this function will fail silently.

Technical Details

  • Type: Function
  • Parameters:
    • $slug (string; required): The slug portion of the template part (i.e. if the template part is named sidebar-custom.php, the "sidebar" portion is the slug)
    • $name (string): The name portion of the template part (i.e. if the template part is named sidebar-custom.php, the "custom" portion is the name)
    • $data (array): Optional data to pass along to the template part; if this parameter is not empty (and is an array), it is passed to the conductor_get_template_part_data filter
    • $wp_globals (Boolean): Whether or not to use WordPress global variables; these include - global $posts, $post, $wp_did_header, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID;
    • $require_once (Boolean): Whether or not to use require_once() to load the template part, otherwise require() is used
  • Return Value: None

Resources

Examples

The following example demonstrates how to use conductor_get_template_part() in a custom Conductor content layout template.