WordPress Conditional Statement for Custom Post Types

I have been trying to create a conditional line that allows me to add more than one ID for a specific custom post type. I use something like the following for single IDs, but I can’t figure out how to do it for multiple IDs:

<?php if ('people' == get_post_type() && get_the_ID() == 107) {  ?>

I have been trying to say something like: If the custom post type is people and the ID is either 107, 109, or 111, then do this. Else, do this…

Read More

Is this possible with custom post types?

Related posts

Leave a Reply

1 comment

  1. You can do it like

    $arr=array(107, 109, 111); // keep all ids in an array that you want check
    <?php if ('people' == get_post_type() && in_array(get_the_ID(), $arr))  { ?>
        ...
    <?php } ?>