Opened 10 years ago
Closed 10 years ago
#14679 closed defect (bug) (invalid)
in_category returns true for parent cat if last item on page is from tested subcat
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0 |
Component: | Template | Keywords: | in_category, categories |
Focuses: | Cc: |
Description
Assume the following category structure
site.com
site.com/category/parent
site.com/category/parent/subcat
If in_category is used to test for subcat, it will return true if the user is viewing site.com/category/parent and its loop is displaying posts from parent and its subcategory, and the last post on the page is from the subcategory.
Viewing pages 2, 3, 4, and 5 of posts led to the diagnosis, and inserting test posts at the end of pages that were showing the problem confirmed the bug.
Upgraded to 3.0.1 to see if the problem was resolved. It persists.
Change History (1)
Note: See
TracTickets for help on using
tickets.
in_category() is meant to test wether the current post in The Loop belongs to a certain category.
You are trying to use it like is_category(), which is a conditional tag.
Reference:
http://codex.wordpress.org/Function_Reference/in_category
http://codex.wordpress.org/Conditional_Tags