简体   繁体   中英

Wordpress: how to use get_categories

I have a ajax call to a php file which uses get_categories(). But it always says "Call to undefined function get_categories()" How can I make it to work? 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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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