• Resolved Matt

    (@webmasterifcj)


    Hello guys,

    Looking to write a condition to show a particualr portion of a navigation if the post parents are 205, 203, 202.

    Here is what I got:

    <?php if(is_page('issues') || $post->post_parent == '205' ){ ?>

    I would like to just add a few more post parent id’s is that possible?

    Like:
    <?php if(is_page('issues') || $post->post_parent == '205', '203','202' ){ ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • MichaelH

    (@michaelh)

    Example of in_array:

    <?php
    if ( in_array('205', array('205','203','202')) ) {
        echo "205 is in the array";
    }
    ?>

    Thread Starter Matt

    (@webmasterifcj)

    I did it like this and it worked:

    <?php if(is_page('issues') || $post->post_parent == '205' || $post->post_parent == '209' || $post->post_parent == '211' || $post->post_parent == '213'){ ?>

    Thanks MichaelH I will try that as well to get clean code

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How write a conditional for multiple post parents?’ is closed to new replies.