Wordpress - get_terms() returns “invalid taxonomy”

2019-01-15 21:37发布

On my local machine it works fine, but on the live server, when I run

get_terms('taxonomy' => 'any_taxonomy');

it returns a list of terms, but if I add any parameter to it like:

get_terms('taxonomy' => 'any_taxonomy','hide_empty' => false);

Then it returns "invalid taxonomy". The issue is not that the taxonomy is not registerd get_taxonomies() before it, it shows that all the taxonomies are registered. If I do this:

    get_terms('taxonomy' => 'category','hide_empty' => false);

The same problem is there, so its not just custom taxonomies.

Any idea what could be causing this issue?

Can anyone suggest a way to diagnose this?

1条回答
在下西门庆
2楼-- · 2019-01-15 22:15

i'd say you are running different versions of wordpress, 4.5 changed the functionality of get_terms()

 get_terms(  array('taxonomy' => 'any_taxonomy','hide_empty' => false) );

Should work, but i also think if you are calling get_terms() before registering your taxonomy is going to cause issues.

查看更多
登录 后发表回答