• Resolved vagamente

    (@vagamente)


    Hi all.

    I’m trying to use the is_page conditional tag with array inside.

    I know that I can declare array inside is_tag, but can I use array of array?

    I mean something like this:

    $paginediservizio=array('355','992','988','990','592','882','528');
    $paginelinguabase=array('1167','1168','1169','1171');
    if (is_page(array($paginediservizio,$paginelinguabase) {
        [...]
    }

    It doesn’t work. No errors, just doesn’t output “true” in the right pages.

    Any suggestion why?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • That’s because you’re passing in a multidimensional array, which won’t work.. and additionally you’re missing two right brackets on the is_page condition (might not exist in your actual code though).

    Merge the two arrays..

    $paginediservizio=array('355','992','988','990','592','882','528');
    $paginelinguabase=array('1167','1168','1169','1171');
    
    $merged_page_ids = array_merge( $paginediservizio, $paginelinguabase );
    
    if( is_page( $merged_page_ids ) ) {
    // Etc...

    Hope that helps..

    Thread Starter vagamente

    (@vagamente)

    Yep… that solved it…

    Thanks

    Happy to help.. 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Using is_page with array’ is closed to new replies.