Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#35146 closed defect (bug) (invalid)

Warnings are generated for a custom taxonomy named "terms"

Reported by: willshouse's profile willshouse Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

We have a custom post type for "classes" and we have been using a custom taxonomy for "terms" which represent something similar to a "semester" in the education system, although "terms" is syntactically correct for this use case.

The taxonomy "terms" works fine, but it seems that somewhere "apply_filters" is being called for "get_terms" which then generates these warnings:

PHP Warning: Missing argument 3 for _post_format_get_terms() in /var/www/public_html/wp-includes/post-formats.php on line 221

I didn't see where "terms" was listed as a 'reserved word' that should not be used for taxonomies on the codex - and in all other regards it seems to work fine - but it would be nice if this error was not thrown.

I am attaching the sample code to create the custom taxonomy.

Attachments (1)

taxonomy-test.php (1.2 KB) - added by willshouse 9 years ago.

Download all attachments as: .zip

Change History (6)

#1 @DrewAPicture
9 years ago

  • Keywords needs-codex added

In this instance, I would add "terms" to the reserved keywords list, and suggest you prefix your taxonomy or post type slugs as a best practice.

Seems as if `get_{$taxonomy}` is being triggered here and mistaken with get_terms.

#2 follow-up: @willshouse
9 years ago

I suggest treating this as a bug instead of just taking the "easy route" and saying it's "off limits"

  • Yes, it's blog software, but people also use it as a platform for many other things - partially because it is so flexible
  • "Terms" seems like an fittingly abstract taxonomy name that could work well in many use cases
  • It would be a small change to the core code to allow this flexibility

That being said, do what you like. I'm not holding my breath for a fix.

#3 in reply to: ↑ 2 @DrewAPicture
9 years ago

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

Replying to willshouse:

I suggest treating this as a bug instead of just taking the "easy route" and saying it's "off limits"

  • Yes, it's blog software, but people also use it as a platform for many other things - partially because it is so flexible
  • "Terms" seems like an fittingly abstract taxonomy name that could work well in many use cases
  • It would be a small change to the core code to allow this flexibility

That being said, do what you like. I'm not holding my breath for a fix.

Respectfully, there isn't really a "fix" for this issue. Core has two established hooks for get_ + your unprefixed taxonomy slug. "terms" is a commonly used keyword in WordPress vernacular. The recommendation would be to follow best-practice and prefix your taxonomy slug to avoid conflicts with core, other plugins or other themes. Perhaps class-term or something.

Feel free to continue the discussion here if you'd like; a ticket doesn't need to remain open for discussion to continue.

Related #31154

#4 @DrewAPicture
9 years ago

  • Keywords needs-codex removed

#5 @majemedia
9 years ago

@willshouse, would school_term be a better description for this case from a UI perspective?

  • Singular: "School Term"
  • Plural: "School Terms"
  • etc

The dashboard custom post type link would be easier to explain and any help documentation wouldn't have to explain the difference between educational "Term" and WordPress "Term".

Note: See TracTickets for help on using tickets.