Wordpress - get_terms() 返回“无效分类法";(这不是钩子问题) [英] Wordpress - get_terms() returns "invalid taxonomy" (this is not a hook issue)

查看:28
本文介绍了Wordpress - get_terms() 返回“无效分类法";(这不是钩子问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的本地机器上它工作正常,但在实时服务器上,当我运行时

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);

然后它返回无效的分类法".问题不在于分类法没有在它之前注册 get_taxonomies() ,它表明所有分类法都已注册.如果我这样做:

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?

推荐答案

我想说你运行的是不同版本的 wordpress,4.5 改变了 get_terms()

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) );

应该可行,但我也认为如果您在注册分类法之前调用 get_terms() 会导致问题.

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

这篇关于Wordpress - get_terms() 返回“无效分类法";(这不是钩子问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆