WordPress.org

Support

Support » Themes and Templates » If is child of parent, but not actual parent page? PHP

If is child of parent, but not actual parent page? PHP

  • Hi there,

    I’m trying to do an if statement that says:

    If you’re on a child of a specific parent page:
    SHOW THIS

    then later:

    If you’re on that specific parent page:
    SHOW THIS

    —————————————–

    I have the code for this, but they conflict. Right now the children work, but the parent page doesn’t. What I’m trying to do is: the children are press articles and the parent page is a list that displays them.

    <?php if ( $post->post_parent=="701" ) { ?>
    <p>Child of parent page 701.</p>
    <?php } ?>

    <?php } if ( is_page(701) ) { ?>
    <p>Parent page.</p>
    <?php } ?>

    Thoughts? Help?

  • The topic ‘If is child of parent, but not actual parent page? PHP’ is closed to new replies.
Skip to toolbar