[wp-hackers] Difference between is_home and is_front_page
John Turner
TurnerJD at cofc.edu
Thu Jan 22 20:09:33 GMT 2009
323 /**
324 * Whether current page query is the front of the site.
325 *
326 * @since 2.5.0
327 * @uses is_home()
328 * @uses get_option()
329 *
330 * @return bool True, if front of site.
331 */
332 function is_front_page () {
333 // most likely case
334 if ( 'posts' == get_option('show_on_front') && is_home() )
335 return true;
336 elseif ( 'page' == get_option('show_on_front') &&
get_option('page_on_front') && is_page(get_option('page_on_front')) )
337 return true;
338 else
339 return false;
340 }
341
342 /**
343 * Whether current page view is the blog homepage.
344 *
345 * @since 1.5.0
346 * @uses $wp_query
347 *
348 * @return bool True if blog view homepage.
349 */
350 function is_home () {
351 global $wp_query;
352
353 return $wp_query->is_home;
354 }
355
John Turner
http://johndturner.com
> From: Nathan Rice <ncrice at gmail.com>
> Reply-To: <wp-hackers at lists.automattic.com>
> Date: Thu, 22 Jan 2009 14:46:49 -0500
> To: <wp-hackers at lists.automattic.com>
> Subject: Re: [wp-hackers] Difference between is_home and is_front_page
>
> Close, but no.
> If your About page is set as your front page, and you are viewing
> http://example.com, then:
> is_home() will return false
> is_front_page() will return true.
>
> If your About page is set as your front page, and your Blog page is set up
> to list blog posts, and you are viewing http://example.com/blog then:
> is_home() will return true
> is_front_page() will retrun false
>
> (Please correct me if I'm wrong, anyone).
>
> Nathan
>
>
> On Thu, Jan 22, 2009 at 2:41 PM, Dan Gayle <dangayle at gmail.com> wrote:
>
>> So, for instance, if the "About" page is set as the home page in options,
>> is_front_page() and is_home() will both return true if I'm looking at
>> http://example.com
>>
>> But if I'm looking at http://example.com/about, is_front_page will return
>> true, while is_home() will return false.
>>
>> That's correct, right?
>>
>>
>>
>> On Jan 22, 2009, at 11:31 AM, Nathan Rice wrote:
>>
>> is_home is limited in that it only returns true if you are on the ACTUAL
>>> home page, whereas is_front_page returns true even if you're using a
>>> specific page as your blog's homepage.
>>>
>>> Nathan
>>>
>>> My Website
>>> http://www.nathanrice.net/
>>>
>>> My Twitter
>>> http://twitter.com/nathanrice
>>>
>>>
>>> On Thu, Jan 22, 2009 at 2:27 PM, Dan Gayle <dangayle at gmail.com> wrote:
>>>
>>> Can anyone explain the difference between is_home() and is_front_page()?
>>>>
>>>> They appear to me, from the Codex documentation, that they do the same
>>>> thing.
>>>> _______________________________________________
>>>> wp-hackers mailing list
>>>> wp-hackers at lists.automattic.com
>>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>>
>>>> _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>
>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
More information about the wp-hackers
mailing list