/ Published in: PHP
URL: http://codebyte.dev7studios.com/post/3313452026/wordpress-is-child-and-is-ancestor
Put the following in your functions.php file:
Expand |
Embed | Plain Text
// Check if page is direct child function is_child($page_id) { global $post; if( is_page() && ($post->post_parent == $page_id) ) { return true; } else { return false; } } // Check if page is an ancestor function is_ancestor($post_id) { global $wp_query; $ancestors = $wp_query->post->ancestors; return true; } else { return false; } }
You need to login to post a comment.
