[wp-trac] [WordPress Trac] #35231: get_terms() doesn't work on Multisite
WordPress Trac
noreply at wordpress.org
Sat Dec 26 19:35:44 UTC 2015
#35231: get_terms() doesn't work on Multisite
--------------------------------+-----------------------------
Reporter: AustinTBiggs | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Networks and Sites | Version: 4.4
Severity: normal | Keywords:
Focuses: multisite |
--------------------------------+-----------------------------
Today I found a bug within WordPress Multisite functions.
From a subsite I tried accessing the terms of a custom taxonomy on site
#1. This worked using get_term_by(), but not with get_terms(). WordPress
returns with "Invalid Taxonomy", however I knew the taxonomy existed.
In order to overcome this, I had to create a custom taxonomy on the
subsite with the ''exact same name''. Then WordPress successfully returned
the terms from site #1.
Below is my code:
{{{
switch_to_blog(1);
$taxonomy = array( 'custom_taxonomy' );
$args = array(
'hide_empty' => false,
'exclude' => array(),
'exclude_tree' => array(),
'include' => array(),
'number' => '',
'fields' => 'all',
);
$terms = get_terms( $taxonomy, $args );
var_dump($terms);
restore_current_blog();
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35231>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list