Snippets

get_current_template() WordPress function.

Add this function to your functions.php file and it will return the current template name when called.

function get_current_template() {
    global $wp_query;
    $template_name = str_replace('.php','',get_post_meta($wp_query->post->ID,'_wp_page_template',true));
    if ( $template_name ) return $template_name;
    else return false;
}

Source: http://techstudio.co/wordpress/there-should-be-a-get_current...

Share this snippet

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Please respect the following rules: No advertising, no spam, no keyword in name field. Thank you!