Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8367623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:12:23+00:00 2026-06-09T13:12:23+00:00

I use the WordPress is_page conditional tag frequently, and typically I am defining a

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:12:25+00:00Added an answer on June 9, 2026 at 1:12 pm

    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

    $isPage = false;
    foreach(range(5, 7) as $page)
    {
        if(is_page($page))
            $isPage = true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use purely numerical permalinks for my wordpress page .As it is
I've created this code, it is supposed to use wordpress metabox functionality to save
is there a wordpress function that I can use to detect pages? example of
How do you use wordpress capabilities (using wp-blog-header.php) and keep the permalinks behave? I
I'm trying to learn MySQL queries for use with Wordpress.... What I do know
We are designing an application that will use Rails and Wordpress to interact with
i'm trying to create a Dynamic Sub-menu to use it in Wordpress, Something like
I have a hierarchical treeview in WPF. I use http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/ for eventbinding with the
I wanted to use the custom field for wordpress to have a different header
I'm trying to use custom meta boxes in wordpress. My goal at the moment

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.