dtah63820 2017-10-05 13:15
浏览 56
已采纳

Wordpress:如何使用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'];
}
?>
  • 写回答

1条回答 默认 最新

  • doucheng2053 2017-10-05 13:21
    关注

    In your ajax php file put below line in the top.

    include_once('../../../wp-load.php');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?