[wp-trac] [WordPress Trac] #16312: is_category() returns false while in index
WordPress Trac
wp-trac at lists.automattic.com
Wed Jan 19 20:16:06 UTC 2011
#16312: is_category() returns false while in index
----------------------------+-----------------------------
Reporter: FrancescoRizzi | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.0.4
Severity: normal | Keywords: category
----------------------------+-----------------------------
Let's say the incoming URL is your typical request for a top-level
category, eg:
http://www.test.com/categorybase/Cat-A
Let's say Cat-A doesn't exist.
Finally, let's say the theme includes both index.php and category.php.
Then, WP calls index.php instead of (as one may expect) category.php -
which may be debatable. However, what I think is a bug is that under these
conditions, a call to is_category() from within index.php returns false.
At least, according to the
[http://core.trac.wordpress.org/browser/tags/3.0.4/wp-
includes/query.php#L172 docs in the source], I would expect it to return
true:
{{{
Whether current page query contains a category name or given category
name.
The category list can contain category IDs, names, or category slugs.
If any of them are part of the query, then it will return true.
}}}
The URL, in fact, did include /categorybase/Cat-A
Yes, WP may not be able to tell that Cat-A is supposed to be a category
because, as stated above, Cat-A does not exist...
The fix may be simply to document that is_category determines
{{{
Whether current page query contains a category name or given category name
(matching only existing categories).
}}}
Alternatively, is_category could return true for any query that ''looks
like'' a requets for a category archive (possibly: any URL starting with
the base prefix + category base + anything beyond that) - which may be the
spirit of is-category (or not - you make the call)
''I'm marking this as bug just because I don't know any better - but I can
see the argument that this should be categorized as enhancement or a doc
issue..''
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16312>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list