WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 9 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: Usurper Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Template Keywords: in_category, categories
Focuses: Cc:
PR Number:

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)

#1 @scribu
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

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

Note: See TracTickets for help on using tickets.