Topher
Member
Posted 11 months ago #
In my theme functions.php I have this code:
$menus = get_terms( 'nav_menu', array( 'hide_empty' => true ) );
and it works great.
I have the same code in a plugin and it says this:
object(WP_Error)#1096 (2) {
["errors"]=>
array(1) {
["invalid_taxonomy"]=>
array(1) {
[0]=>
string(16) "Invalid taxonomy"
}
}
["error_data"]=>
array(0) {
}
}
Why would context matter? And what can I do about it?
Topher
Member
Posted 11 months ago #
I figured it out. My test was simply calling my function in the plugin, which was too early in the init. Hooking my function to init made it fire later, and showed me that it was indeed getting the right data.
cyberwani
Member
Posted 10 months ago #
@Toper
I am getting the same error...
WP_Error Object ( [errors] => Array ( [invalid_taxonomy] => Array ( [0] => Invalid taxonomy ) ) [error_data] => Array ( ) )