Hi again,
I found the problem for your situation. Your check doesn't run when post is updated, because there's no $GET['post']
. In that case, you need to get post ID via $_POST
. Here is the code:
function prefix_parent_page_id_check() {
$parents = get_post_ancestors( prefix_get_post_id() );
return $parents && 901 == array_pop( $parents );
}
function prefix_get_post_id() {
if ( isset( $_GET['post'] ) ) {
return intval( $_GET['post'] );
}
if ( isset( $_POST['post_ID'] ) ) {
return intval( $_POST['post_ID'] );
}
return false;
}