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

Danny G Smith dgs at riskiii.com
Wed May 12 13:57:04 UTC 2010


That will be a perfect solution, thanks.  I need to spend more time in the code, I didn't know get_page_by_path() was there.  I need to write a is_subpage_by_path() too, but that will get me started.

thanks,
Danny

On May 12, 2010, at 2:14 AM, John Blackbourn wrote:

> On Wed, May 12, 2010 at 8:12 AM, John Blackbourn
> <johnbillion+wp at gmail.com> wrote:
>> 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
>> 
> 
> You need to use the page slug when calling that function by the way,
> eg in your case is_page_by_path( 'education-outreach') .
> _______________________________________________
> wp-testers mailing list
> wp-testers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-testers



More information about the wp-testers mailing list