简体   繁体   English

Wordpress:如何使用 get_categories

[英]Wordpress: how to use get_categories

I have a ajax call to a php file which uses get_categories().我对使用 get_categories() 的 php 文件进行了 ajax 调用。 But it always says "Call to undefined function get_categories()" How can I make it to work?但它总是说“调用未定义的函数 get_categories()”我怎样才能让它工作? What should be included?应该包括什么?

<?php
if(isset($_GET['slug'])) {
    echo get_categories(array('taxonomy' => 'product_cat'))[0]['slur'];
}
?>

在您的 ajax php 文件中,将下面的行放在顶部。

include_once('../../../wp-load.php');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM