help writing a function or filter to shorten a long if statement
-
Hi,
I am not sure how to properly ask this, aka what terms to use, but hopefully someone can steer me in the right direction.I want to write something into my functions.php which basically allows me to abbreviate a very long if statement and call it from other files within my theme:
<?php $ancestors = get_post_ancestors($post); if((is_page(array('2641','2654','2656','2658','2660','2662','2664'))) || (in_array(2641,$ancestors)) || (in_array(2654,$ancestors)) || (in_array(2656,$ancestors)) || (in_array(2658,$ancestors)) || (in_array(2660,$ancestors)) || (in_array(2662,$ancestors)) || (in_array(2664,$ancestors))) { ?>do something<? } ?>
I was thinking that when I call it from other files in my theme, the code would look like this:
<?php if(is_concierge_page()) { ?> do something <? } ?>
Does that make sense? Can someone help me write this?
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘help writing a function or filter to shorten a long if statement’ is closed to new replies.