Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellenmace/c6ab8aa769d90f7902d3c12562116fd7 to your computer and use it in GitHub Desktop.
Save kellenmace/c6ab8aa769d90f7902d3c12562116fd7 to your computer and use it in GitHub Desktop.
Get Page Template for Post in WordPress Admin
<?php
/**
* Return true if page template is being used, else false.
*
* @param string $page_template The filename of the template to check against.
* Example: 'abc-123.php'.
*
* @return bool Whether page template is being used.
*/
function km_is_page_template( $page_template ) {
global $post;
if ( ! $post ) {
return false;
}
return $page_template === get_post_meta( $post->ID, '_wp_page_template', true );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment