Php get_terms()显示插件分类的错误
我在wordpress插件文件夹中有这段代码,Php get_terms()显示插件分类的错误,php,wordpress,Php,Wordpress,我在wordpress插件文件夹中有这段代码,localhost/wp content/plugins/test/cat.php <? define( "WP_INSTALLING", true ); require ('../../../wp-blog-header.php'); $categories = get_terms("ad_cat","parent=6&hide_empty=0"); print_r($categories); ?> 但是,当我在侧栏小部件
localhost/wp content/plugins/test/cat.php
<?
define( "WP_INSTALLING", true );
require ('../../../wp-blog-header.php');
$categories = get_terms("ad_cat","parent=6&hide_empty=0");
print_r($categories);
?>
但是,当我在侧栏小部件中使用PHP代码插件做同样的事情时,没有任何错误。分类法
ad_cat
存在,它是使用Wordpress分类广告主题自动创建的。当我使用分类法category
这是wordpress的默认类别时,它就起作用了。但是,我想让它显示的ad_cat
Wordpress在添加任何主题文件之前添加插件文件。所以你们不能在插件中得到修改过的主题数据
所以,您必须等待添加主题文件
考虑add_action
和add_hook
来钩住自定义函数。这将使自定义函数中的所有数据可用删除定义(“WP_安装”,true)代码>这将解决该项目。这对我很管用
WP_Error Object
(
[errors] => Array
(
[invalid_taxonomy] => Array
(
[0] => Invalid Taxonomy
)
)
[error_data] => Array
(
)
)