[wp-trac] [WordPress Trac] #16347: is_post_type_archive doesn't return correctly outside of loop
WordPress Trac
wp-trac at lists.automattic.com
Sat Jan 22 19:29:05 UTC 2011
#16347: is_post_type_archive doesn't return correctly outside of loop
--------------------------+----------------------------------------------
Reporter: blt4 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Post Types | Version: 3.1
Severity: normal | Keywords: is_post_type_archive, post types
--------------------------+----------------------------------------------
The new {{{is_post_type_archive}}} function depends on the loop being
started ({{{$this->posts}}} set) to function correctly when post types are
passed to the function. The function should return correctly even if the
loop hasn't been started (aka in a posts_where filter).
For example, from a posts_where filter on an "event" archive page:
'''Correct:'''
{{{
is_post_type_archive() => true
}}}
'''Incorrect''' (should return ''true''):
{{{
is_post_type_archive('event') => false
}}}
I am not a Wordpress developer, but I would replace the
{{{is_post_type_archive}}} function in {{{wp-includes/query.php}}} with:
{{{
function is_post_type_archive( $post_types = '' ) {
if ( empty( $post_types ) || !$this->is_post_type_archive )
return (bool) $this->is_post_type_archive;
return in_array( $this->query_vars['post_type'], (array) $post_types
);
}
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16347>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list