[wp-trac] [WordPress Trac] #57131: get_the_terms(): Parameter #1 ($post) of type is nullable.

WordPress Trac noreply at wordpress.org
Thu Nov 17 22:48:54 UTC 2022


#57131: get_the_terms(): Parameter #1 ($post) of type is nullable.
-----------------------------------+------------------------------
 Reporter:  omaeyusuke             |       Owner:  (none)
     Type:  enhancement            |      Status:  new
 Priority:  normal                 |   Milestone:  Awaiting Review
Component:  Taxonomy               |     Version:  3.6
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:  docs
-----------------------------------+------------------------------

Comment (by peterwilsoncc):

 Replying to [comment:3 SergeyBiryukov]:
 > Curious to see what others think.

 I think it becomes a question of what WordPress documents: is it the
 recommended approach or what is technically feasible.

 To get the terms for the current global post, I would personally recommend
 `get_the_terms( get_the_ID() /* or get_post() */, 'category' );` to
 provide clarity; passing `null` is technically possible and likely will
 remain supported.

 I'm in two minds but am leaning towards documenting the technically
 possible that `null` is supported.

 If they don't exist already, I'd certainly like to see some tests added to
 ensure compatibility is maintained.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57131#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list