代码之家  ›  专栏  ›  技术社区  ›  Aman

正在获取wordpress网络站点中可用的类别列表

  •  1
  • Aman  · 技术社区  · 15 年前

    在我的插件中,我试图获取所有可用网络网站中可用的类别列表。

    是否可以不编写SQL查询?

    2 回复  |  直到 15 年前
        1
  •  0
  •   rexposadas    15 年前

    我相信你可以使用:get\u all\u category\u ids()

    该功能位于wp中,包括\类别.php

    更多信息: http://codex.wordpress.org/Function_Reference/get_all_category_ids

        2
  •  0
  •   Aman    15 年前

    我知道答案了。 如果我们所有的博客id都在一个数组中 $blog_id_list ,然后我们可以:

    foreach($blog_id_list as $blog_id)
    {
        switch_to_blog($blog_id);
        get_categories(); //use it as required.
    }
    restore_current_blog();