[wp-trac] [WordPress Trac] #64357: get_terms() no longer returns terms when "include" or "exclude" is set to 'all' or an empty value in WP 6.9
WordPress Trac
noreply at wordpress.org
Fri Dec 5 11:52:07 UTC 2025
#64357: get_terms() no longer returns terms when "include" or "exclude" is set to
'all' or an empty value in WP 6.9
--------------------------+------------------------------
Reporter: ibachal | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: 6.9
Severity: major | Resolution:
Keywords: has-patch | Focuses:
--------------------------+------------------------------
Changes (by iflairwebtechnologies):
* keywords: => has-patch
Comment:
**Summary:**
This patch fixes a regression introduced in WordPress 6.9 where
**get_terms()** fails to return any terms when the **include** or
**exclude** arguments are passed as an empty value (**[], '', null**) or
when **'include' => 'all' / 'exclude' => 'all'** is used. These values
should result in no filtering, but in WP 6.9 they incorrectly produce no
results.
**Issue:**
Previously, an empty **include** or **exclude** argument behaved as a no-
op.
After WP 6.9 changes in **WP_Term_Query::get_sql_for_clause()**, empty
term sets were treated as invalid and returned **self::$no_results**. This
broke several common usages including:
- Calling get_terms(** [ 'include' => [] ]** )
- Passing an empty string via REST or shortcode
- Plugins using **'include' => 'all'** to indicate no filtering
- Core internals expecting empty arrays to behave as wildcard matches
**What this patch does:**
- Restores pre-6.9 behavior
- Ensures empty / invalid / "all" includes and excludes do NOT filter
terms
- Prevents IN () and NOT IN () SQL from being generated
- Normalizes terms before generating SQL
- Maintains backward compatibility for all existing plugins, REST API,
and shortcode usage
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64357#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list