WordPress.org

Make WordPress Core

Changeset 37656


Ignore:
Timestamp:
06/08/2016 04:07:47 AM (3 years ago)
Author:
boonebgorges
Message:

Add a note about uniqueness to the doc block for get_term_by().

get_term_by() always returns a single term, even when more than one term
matches the query parameters. The new note warns developers to use
get_terms() when such ambiguity may result.

Fixes #36878.

File:
1 edited

Legend:

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

    r37634 r37656  
    902902 * If $value does not exist, the return value will be false. If $taxonomy exists
    903903 * and $field and $value combinations exist, the Term will be returned.
     904 *
     905 * This function will always return the first term that matches the `$field`-
     906 * `$value`-`$taxonomy` combination specified in the parameters. If your query
     907 * is likely to match more than one term (as is likely to be the case when
     908 * `$field` is 'name', for example), consider using get_terms() instead; that
     909 * way, you will get all matching terms, and can provide your own logic for
     910 * deciding which one was intended.
    904911 *
    905912 * @todo Better formatting for DocBlock.
Note: See TracChangeset for help on using the changeset viewer.