Make WordPress Core

Changeset 55018


Ignore:
Timestamp:
12/27/2022 12:21:35 PM (22 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r55011 r55018  
    12301230 * along with the $args array.
    12311231 *
    1232  * Prior to 4.5.0, the first parameter of `get_terms()` was a taxonomy or list of taxonomies:
    1233  *
    1234  *     $terms = get_terms( 'post_tag', array(
     1232 * Taxonomy or an array of taxonomies should be passed via the 'taxonomy' argument
     1233 * in the `$args` array:
     1234 *
     1235 *     $terms = get_terms( array(
     1236 *         'taxonomy'   => 'post_tag',
    12351237 *         'hide_empty' => false,
    12361238 *     ) );
    12371239 *
    1238  * Since 4.5.0, taxonomies should be passed via the 'taxonomy' argument in the `$args` array:
    1239  *
    1240  *     $terms = get_terms( array(
    1241  *         'taxonomy' => 'post_tag',
    1242  *         'hide_empty' => false,
    1243  *     ) );
     1240 * Prior to 4.5.0, taxonomy was passed as the first parameter of `get_terms()`.
    12441241 *
    12451242 * @since 2.3.0
Note: See TracChangeset for help on using the changeset viewer.