{"id":1204325,"date":"2009-09-07T17:15:01","date_gmt":"2009-09-07T17:15:01","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/is_tree-function\/"},"modified":"2016-08-19T13:54:25","modified_gmt":"2016-08-19T13:54:25","slug":"is_tree-function","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/is_tree-function\/","title":{"rendered":"is_tree() function"},"content":{"rendered":"<p>Why isn&#8217;t the conditional function is_tree() a CORE part of WordPress? Why do I have to add it to use it? <\/p>\n<p>If you&#8217;ve EVER struggled over trying to make dynamic sidebars or includes or any other changes that should propagate to a page and it&#8217;s children, check out is_tree(); IT ROCKS and it SHOULD be built into the program by default, imo.<\/p>\n<p>https:\/\/codex.wordpress.org\/Conditional_Tags  (scroll down to snippet4)<\/p>\n<p>Here&#8217;s the function, but you have to add it to use it per instructions on the Conditionals Tags page:<\/p>\n<pre><code>function is_tree($pid) {      \/\/ $pid = The ID of the page we&#039;re looking for pages underneath\n\tglobal $post;         \/\/ load details about this page\n\tif(is_page()&amp;&amp;($post-&gt;post_parent==$pid||is_page($pid)))\n               return true;   \/\/ we&#039;re at the page or at a sub page\n\telse\n               return false;  \/\/ we&#039;re elsewhere\n};<\/code><\/pre>\n<p>Vote here: https:\/\/wordpress.org\/extend\/ideas\/topic.php?id=3139<\/p>\n","protected":false},"template":"","class_list":["post-1204325","topic","type-topic","status-closed","hentry","topic-tag-child-pages","topic-tag-conditional-tags","topic-tag-functions","topic-tag-pages"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/1204325","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/1204325\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=1204325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}