diff --git a/core/Container/Condition/Post_Template_Condition.php b/core/Container/Condition/Post_Template_Condition.php index ad4f13259..e1b0b0be3 100644 --- a/core/Container/Condition/Post_Template_Condition.php +++ b/core/Container/Condition/Post_Template_Condition.php @@ -20,6 +20,12 @@ public function is_fulfilled( $environment ) { $is_page_for_posts = intval( $post_id ) === intval( get_option( 'page_for_posts' ) ); $post_template = get_post_meta( $post_id, '_wp_page_template', true ); + + // If this is a revision, there may not be a _wp_page_template record, so look up the parent template. + if ( ! $post_template && 'revision' === get_post_type( $post_id ) ) { + $post_template = get_post_meta( $environment['post']->post_parent, '_wp_page_template', true ); + } + if ( ! $post_template || $is_page_for_posts ) { $post_template = 'default'; } @@ -30,4 +36,4 @@ public function is_fulfilled( $environment ) { $this->get_value() ); } -} \ No newline at end of file +}