delarge
1/17/2019 - 12:55 PM

WP template slug

Useful for adding as a class

function template_slug($post_id = NULL) {

	if (!$post_id) {
		$post_id = $post->ID;
	}

	$template_slug = get_page_template_slug( $post_id );
	$template_slug = sanitize_title($template_slug);
	$template_slug = str_replace('-php', '', $template_slug);

	return $template_slug;

//

}