Wordpress - get_terms() returns “invalid taxonomy” (this is not a hook issue)

南笙酒味 提交于 2019-12-28 07:07:23

问题


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:


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.



来源:https://stackoverflow.com/questions/36898313/wordpress-get-terms-returns-invalid-taxonomy-this-is-not-a-hook-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!