即使分类法存在,taxonomy_exists 也总是返回 false [英] taxonomy_exists always return false even the taxonomie exist

查看:43
本文介绍了即使分类法存在,taxonomy_exists 也总是返回 false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

验证分类法存在的 Wordpress 函数 taxonomy_exists 总是返回 false.

Wordpress function taxonomy_exists that verifies the existence of taxonomy always returns false.

 $tax = taxonomy_exists('categorie-video');
 error_log('verify the existence of taxonomy = ' . json_encode($tax));

我使用了Simple Taxonomy 插件来创建分类法.

I used Simple Taxonomy plugin to create the taxonomy.

推荐答案

这取决于您调用 taxonomy_exists() 函数的位置.

This depends on the place where you are calling the taxonomy_exists() function.

分类是在 init 钩子上创建的.因此,在 init 钩子之前调用 taxonomy_exists() 将返回 false,因为任何分类法尚未初始化.

Taxonomies are created on init hook. So, calling taxonomy_exists() before init hook will return false because any taxonomy has not been initialized yet.

这篇关于即使分类法存在,taxonomy_exists 也总是返回 false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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