Make WordPress Core

Opened 10 years ago

Closed 3 years ago

#36654 closed enhancement (wontfix)

New function `has_terms`

Reported by: sebastian.pisula Owned by:
Priority: normal Milestone:
Component: Taxonomy Version:
Severity: normal Keywords: has-patch needs-unit-tests reporter-feedback
Cc: Focuses:

Description

I suggest add new function:

if(has_terms('category')) {
the_terms(x, 'category');
}

Attachments (1)

36654.patch​ (877 bytes ) - added by sebastian.pisula 10 years ago.

Download all attachments as: .zip

Change History (5)

#1 @swissspidy
10 years ago

  • Keywords has-patch needs-unit-tests added

#2 @Mte90
9 years ago

  • Keywords reporter-feedback added

What is the difference with has_term?
I think that are the same but only with different code approach, instead has_terms has 3 parameter that add the support for term and not only for taxonomy.

#3 @Mte90
3 years ago

So after all these years, I don't think that this function is needed.

​https://developer.wordpress.org/reference/functions/has_term/

Has_term support as parameter an array, so it is possible to specify multiple terms.

#4 @swissspidy
3 years ago

  • Milestone Awaiting Review
  • Resolution → wontfix
  • Status new → closed

Agreed, and if no terms are given to has_term(), it determines if post has any terms, which seems exactly what the function here would be doing.

Note: See TracTickets for help on using tickets.