• oliverm

    (@oliverm)


    Hi chaps,

    Can someone help me create a conditional statement please? I want to assign the ID of the current page to a variable IF it itself has no parent. If the page has a parent then i want the variable to contain the ID of the parent page.

    Olly

Viewing 1 replies (of 1 total)
  • stvwlf

    (@stvwlf)

    <?php
    if ($post->post_parent > 0) {
       $myID = $post->post_parent;
    } else {
       $myID = $post->ID;
    }
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Help with conditional statement’ is closed to new replies.