Make WordPress Core

#57380 closed enhancement (fixed)

[documentation] get_terms basic usage order

Reported by: ramon-fincken's profile ramon fincken Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.2 Priority: normal
Severity: normal Version: 4.5
Component: Taxonomy Keywords: has-patch
Focuses: docs Cc:

Description

Currently, the https://developer.wordpress.org/reference/functions/get_terms/ page shows the deprecated way of calling get_terms for taxonomy "X", followed by the more recent ( 4.5.0 ) way of calling get_terms

I for one mis-copy pasted the first piece of code. Why not switch the two exmple blocks ?
Or even delete the deprecated block of code as 4.5.0 was released in April 2016 ... which is quite a while ago. ( https://wordpress.org/support/wordpress-version/version-4-5/ )

Attachments (1)

57380.20221223.1.patch (1.1 KB) - added by ramon fincken 23 months ago.
57380.20221223.1.patch

Download all attachments as: .zip

Change History (3)

@ramon fincken
23 months ago

57380.20221223.1.patch

#1 @sabernhardt
23 months ago

  • Milestone changed from Awaiting Review to 6.2
  • Version changed from trunk to 4.5

The "Prior to 4.5.0" sentence is probably worth keeping, at the end, but removing the old code example could help avoid confusion.

#2 @SergeyBiryukov
23 months ago

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

In 55018:

Docs: Remove the legacy example of passing a taxonomy to get_terms().

As of WordPress 4.5, taxonomies should be passed to get_terms() via the taxonomy argument in the $args array:

$terms = get_terms( array(
    'taxonomy'   => 'post_tag',
    'hide_empty' => false,
) );

The legacy way of passing a taxonomy via the function's first parameter was still mentioned in the documentation, causing some confusion.

This commit updates the function documentation to better highlight the currently recommended approach.

Follow-up to [36614].

Props ramon-fincken, sabernhardt, SergeyBiryukov.
Fixes #57380.

Note: See TracTickets for help on using tickets.