• I am developing in the site editor and need to get the name of the current template, but I don’t know if there is such a function to get the name of the template.

    $check_post_type = get_post_type($post_id);
    if ($check_post_type == 'wp_template') {
      $fileName = ...MY_TEMPLATE_NAME...;
    }
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The template used is determined dynamically during the request, so there is no guarantee a particular template will be used during editing. The template eventually used will depend upon the currently active theme and the current context, which can change many times over the life of a post.

    You could determine the probable template for the current theme by calling get_single_template(), but the returned value could be different in the next edit session.

Viewing 1 replies (of 1 total)
  • The topic ‘How can I get the template name in site editor’ is closed to new replies.