I use the WordPress is_page conditional tag frequently, and typically I am defining a single ID, or an array of ID’s to include, or exclude from displaying some custom code.
What I’m trying to figure out, is whether I can define a range of ID’s to feed in as an argument.
Here is a simple example of using the is_page condition:
<?php if(is_page( 5 ): ?>
<p>This is some text</p>
<?php endif; ?>
Here is a simple example of using the id_page condition with an array:
<?php if(is_page( array( 5,6,7 ) ): ?>
<p>This is some text</p>
<?php endif; ?>
What I’d like to do, is have this where I can pass through an argument, and define that as a range of ID’s such as 5-7:
$arg = 5-7;
<?php if(is_page( $arg ): ?>
<p>This is some text</p>
<?php endif; ?>
Where I’m defining the arg, I think it’s a matter of maybe setting a boundary, defining an array, and placing that in a foreach statement, but I’m still trying to wrap my head around it all.
According to http://codex.wordpress.org/Function_Reference/is_page, you can’t use it as a range. However, I’d use this function instead