From 501e4d2140ed0762670adf717bcf8555150ff18e Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Wed, 9 May 2018 08:37:49 -0400 Subject: [PATCH] adding is in tree function to the functions file --- functions.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/functions.php b/functions.php index 7fb5f80..5937126 100644 --- a/functions.php +++ b/functions.php @@ -177,7 +177,27 @@ function is_post_type($type){ if($type == get_post_type($wp_query->post->ID)) return true; return false; } - +/* + * This function returns true when the current page is the page given by ID + * or a descendent thereof. + */ +if (!function_exists('is_in_tree')) { + function is_in_tree( $pid ) { + global $post; + if ( is_page( $pid ) ) { + return true; + } + if ($post) { + $anc = get_post_ancestors( $post->ID ); + foreach ( $anc as $ancestor ) { + if( is_page() && $ancestor == $pid ) { + return true; + } + } + } + return false; + } +} add_action('thematic_searchloop', 'mytheme_search_loop'); // End of the Contextual/Highlight Search functions ?> -- 2.17.1