Check if page parent has certain template

This question has been answered on Stack Overflow before:
https://stackoverflow.com/a/14626254/844732

add_action( 'admin_head', 'check_page_template' );
function check_page_template() {
    global $post;
    if ( 'page-homepage.php' == get_post_meta( $post->ID, '_wp_page_template', true ) ) {
        // The current page has the foobar template assigned
        // do something

    }
}

Leave a Comment