[wp-testers] is_page('Education & Outreach')

John Blackbourn johnbillion+wp at gmail.com
Wed May 12 07:12:45 UTC 2010


On Wed, May 12, 2010 at 2:45 AM, Danny G Smith <dgs at riskiii.com> wrote:
> It appears that is_page is not sanitizing the input text, at least that is my guess, when I use 'Education & Outreach' which it the page title, it does not work, but if I use the page number 25 it does.

is_page() only accepts a page ID or an array of page IDs to check. It
would probably be useful if it did accept page names (or more
specifically, page paths).

I usually stick a wrapper function in my theme's functions.php file:

function is_page_by_name( $name ) {
    $page = get_page_by_path( $name );
    if ( $page )
        return is_page( $page->ID );
    return false;
}

John


More information about the wp-testers mailing list