PHP 37
WP get assigned template name - get_page_template By micha on 3rd July 2024 08:26:33 AM
  1. <?php
  2.         $page_id = get_the_ID();
  3.         $template = basename( get_page_template($page_id), '.php' );
  4.  
  5.         if (empty($template)) {
  6.                 $template = 'unset';
  7.         }
  8.  
  9.         echo $template;
  10. ?>

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.