我需要检索带有类别名称的数组。
似乎标签名称和类别名称都存储在同一个表(wp_terms
)中,为了区分它们,您需要查看列出wp_terms的ID的wp_term_taxonomy
表。 options post_tag或category。
所以我需要做一些关系查询,说实话,这比我现在能处理的要多得多。我确实发现显然存在某种捷径。我无法找到对该功能的良好描述,但如果你考虑这个:$ wpdb-> categories-> cat_name`你可能知道它的全部内容。我当然不会。
如何获得包含所有已定义类别名称的数组,包括其他内容?
答案 0 :(得分:2)
http://codex.wordpress.org/Function_Reference/get_categories
我发现文档实际上非常好。
编辑:
如果您只是需要静态菜单,请使用菜单面板,首先在主题中添加对它的支持:
add_theme_support( 'menus' );
答案 1 :(得分:2)
您可以使用get_categories
。
http://codex.wordpress.org/Function_Reference/get_categories
这将获取所有类别
get_categories(array('hide_empty' => 0));
答案 2 :(得分:1)
我原以为使用get_categories();
会对你有用。在手抄本中的文档看起来非常简单。您可以确切了解get_categories()
wp_list_categories()
的确切方式
很多时候,当我找不到合适的文档时,我只是想像“Worpdress Codex Get'xxx'”这样的东西,我可以找到我需要的东西。
如果get_categories()
适合您,请告诉我们。
http://codex.wordpress.org/Function_Reference/get_categories