• Hi!

    I was reading the doc about conditional tags and decided to add the is_tree() function to my theme. So, as proposed, I added the snippet 4 to my themes functions.php.

    Looks like:

    <?php
    
    if ( function_exists('register_sidebars') )
            register_sidebars(2);
    ?>
    function is_tree($pid) {      // $pid = The ID of the page we're looking for pages underneath
    	global $post;         // load details about this page
    	if(is_page()&&($post->post_parent==$pid||is_page($pid)))
                   return true;   // we're at the page or at a sub page
    	else
                   return false;  // we're elsewhere
    };

    But now on the top of my page I see the text of the added function.
    Seems like I added just a textparagraph. Am I missing something?
    Anyone who can explain to me how to add this function properly to my functions.php?

    any help appreciated,
    cya, piedro

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Functions and other PHP code must be INSIDE the <?php and ?> tags. Anything outside those tags is not PHP, it’s treated as normal HTML.

    Thread Starter YoChen

    (@piedro)

    thx otto!

    Things can be so easy. Works now. What a great relief!
    I think the is_tree function should be included anyway – it’s just sohandy for conditional designs …

    thx again,
    cu, piedro

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘function is_tree (from docs: “Conditional Tags”)’ is closed to new replies.