get template name wordpress

To get the template name in WordPress, you can use the get_template() function. Here are the steps:

Step 1: Open the WordPress theme files.

Step 2: Locate the file where you want to display or use the template name.

Step 3: Insert the following code snippet:

<?php
$template_name = get_template();
echo "The current template name is: " . $template_name;
?>

Step 4: Save the file.

This code retrieves the name of the active theme's directory and assigns it to the $template_name variable using the get_template() function. Then, it displays the template name using echo.