Skip to content

Instantly share code, notes, and snippets.

@JeroenSormani
Created July 24, 2015 05:05
WooCommerce load template file
<?php
/**
* Get template.
*
* Search for the template and include the file.
*
* @since 1.0.0
*
* @see wcpt_locate_template()
*
* @param string $template_name Template to load.
* @param array $args Args passed for the template file.
* @param string $string $template_path Path to templates.
* @param string $default_path Default path to template files.
*/
function wcpt_get_template( $template_name, $args = array(), $tempate_path = '', $default_path = '' ) {
if ( is_array( $args ) && isset( $args ) ) :
extract( $args );
endif;
$template_file = wcpt_locate_template( $template_name, $tempate_path, $default_path );
if ( ! file_exists( $template_file ) ) :
_doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $template_file ), '1.0.0' );
return;
endif;
include $template_file;
}
@mi5t4n
Copy link

mi5t4n commented Mar 27, 2019

In the parameter, there is mistake in parameter name. It is $tempate_path instead of $template_path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment