**
* Check whether we are on a subpage
*
* @return mixed ID of the parent post or false if this is not a subpage.
*/
function wpdocs_is_subpage() {
// Load details about this page.
$post = get_post();
// test to see if the page has a parent
if ( is_page() && $post->post_parent ) {
// Return the ID of the parent post.
return $post->post_parent;
// There is no parent so ...
} else {
// ... The answer to the question is false
return false;
}
}
Is it a subpage of the page id 129?
So in your functions.php file:
And in your page.php or where ever:
Source