title: Finding out which Wordpress template is used for a page from admin page
body: <p>I'm trying to retrieve the filename/path of template used on the 'Edit Page'-page in the Dashboard.</p>
  <p>Similar to what <code>wp-includes/template-loader.php</code> (<a href="https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/template-loader.php" rel="noreferrer">source</a>) does on the front end: finding out which template to render.</p>
  <p>Unfortunately, expressions like <code>is_front_page()</code> - which Wordpress' <code>template-loader.php</code> uses to find out if it should use <code>get_front_page_template()</code> - don't work correctly on the admin page. Which is to be expected because those expression use the global $wp_query object, and not the current query.</p>
  <p>What I've tried so far:</p>
  <p><strong>Running a post loop inside the admin page</strong></p>
  <pre><code>$args = array(
      'p' =&gt; get_the_ID(),
      'post_type' =&gt; 'any'
  );
  
  $query = new \WP_Query($args);
  
  if ( $query-&gt;have_posts() ) : while ( $query-&gt;have_posts() ) : $query-&gt;the_post(); ?&gt;
  
      &lt;?= the_title(); ?&gt;&lt;br&gt;
      Is front page: &lt;?= is_front_page() ? 'true' : 'false' ?&gt;
  
  &lt;?php endwhile; endif; ?&gt;
  </code></pre>
  <p>Displays:</p>
  <blockquote>
  <p>Home</p>
  <p>Is front page: false</p>
  </blockquote>
  <p><strong>Using get_post_meta</strong></p>
  <pre><code>&lt;?= get_post_meta(get_the_ID(), '_wp_page_template', true); ?&gt;
  </code></pre>
  <p>Displays:</p>
  <blockquote>
  <p>default</p>
  </blockquote>
  <p>...which would be the same for front-page.php on Home and page.php on another default page, so this doesn't help me.</p>
  <p><strong>In short</strong></p>
  <p>What I'm trying to get is <code>front-page.php</code> when I'm editing my 'Home' page. Or <code>custom-template.php</code> when I'm editing some page with the custom template selected. Or <code>about-page.php</code> when I'm editing a page called 'About'. How to get the correct filename or path?</p>