#5430 closed enhancement (fixed)
Change is_page() to accept array as argument
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | normal | Version: | 2.3.1 |
Component: | Template | Keywords: | has-patch |
Focuses: | Cc: |
Description
I often see
if ( is_page(3) || is_page(8) || is_page(15) )
... etc. in templates. Same goes for is_single(), is_author(), is_category() and perhaps is_tag(). It would be much cleaner/easier if these conditional tags can accept an array as argument as well. The attached patch changes the is_page() function to accept an array of page IDs, page slugs or page titles and can be used like this:
$my_pages = array ( 3, 'another-page', 'Special Page' ); if ( is_page( $my_pages ) ) $do_something...
It is (of course) backwards compatible and there's no noticeable performance hit at all, as is_page() is called just once instead of several times.
Attachments (1)
Change History (7)
Note: See
TracTickets for help on using
tickets.
The attachment didn't come up as expected, sry. Here's the change
line 155 in query.php, instead of:
add: