• Resolved ratamatcat

    (@ratamatcat)


    Hello,

    Is there a method that lets me take the page ID’s under the ‘if’ statement and put them somewhere else to manage and then refer to by a shorter name in a template. So then I can reuse a simpler word, such as I put into the 2nd code section below as ‘group 1’.

    <?php
    if ( is_page([1172,1170,1269,1271,1273])) {
    the_field(‘exotic’, ‘option’);
    ?>

    <?php
    if ( is_page([group 1])) {
    the_field(‘exotic’, ‘option’);
    ?>

    The reason is this same set of page ID’s will be repeated throughout in my template file to do different stuff, display custom fields mostly. And the list of page ID’s is going to be much larger.

    thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,
    You can define in a array variable like this.

    $pagesIn = array(1,2,3,4,5); // you can add more page ids like this.

    Now use in your code:-

    <?php
    if ( is_page($pagesIn) {
    the_field(‘exotic’, ‘option’);
    ?>

    Thanks
    Mohammad

    Thanks
    Mohammad

    Thread Starter ratamatcat

    (@ratamatcat)

    Hey Mohammad this is great.

    (I like your little test but I eventually discovered it, the missing bracket!)

    Hi,
    You are right. I missed a bracket. Anyway glad 🙂 to help you. Just mark this issue as resolve.
    Thanks
    Mohammad

    Thread Starter ratamatcat

    (@ratamatcat)

    thanks for the info!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘managing large number of page ID’s with is_page conditional’ is closed to new replies.