WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#19671 closed enhancement (fixed)

Only retrieve categories list if post type supports categories

Reported by: niallkennedy Owned by: nacin
Milestone: 3.4 Priority: normal
Severity: minor Version: 3.3
Component: Performance Keywords: has-patch commit
Focuses: Cc:

Description

The get_the_category_list function attempts to pull a list of categories before it checks if a category relationship applies to the current post_type. Attached patch moves the category retrieval down a few lines: after we've determined a category relationship could exist.

Before

  • Fetch and assign all categories to a variable
  • Test if post type uses categories

After

  • Test if post type uses categories
  • Fetch and assign all categories to a variable

Saves fetch time and filtering for post types without a category relationship.

Attachments (1)

category-template.diff (780 bytes) - added by niallkennedy 2 years ago.
attempt to fetch categories if categories applicable for post type

Download all attachments as: .zip

Change History (4)

niallkennedy2 years ago

attempt to fetch categories if categories applicable for post type

comment:1 scribu2 years ago

  • Component changed from Template to Performance
  • Milestone changed from Awaiting Review to 3.4

comment:2 nacin2 years ago

  • Keywords commit added

comment:3 nacin2 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In [20622]:

Don't call get_the_category() in get_the_category_list() unless the post type supports categories. props niallkennedy. fixes #19671.

Note: See TracTickets for help on using tickets.