Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get Page Template for Post in WordPress Admin
* Return true if abc-123 page template is being used, else false.
* @return bool Whether abc-123 page template is being used.
function km_is_abc_123_template() {
global $post;
if ( ! $post ) {
return false;
return 'abc-123.php' === 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