如何获取与BuddyPress相关的所有WordPress页面?我的意思是,我将通过下面的图片详细说明:
每个人都可以根据图像看到有5个页面(小部件,测试目的,主页,关于我们,博客),这些是由我创建的WordPress页面,所有这些页面都分配给BuddyPress组件目录。现在我想获得所有这些分配的页面。是否有用于此目的的内置函数或是否有任何策略来获取这些页面?
答案 0 :(得分:1)
您应该能够使用文件bp_core_get_directory_page_ids
中定义的函数bp-core/bp-core-functions.php
。
/**
* Fetch a list of BP directory pages from the appropriate meta table.
*
* @since BuddyPress (1.5.0)
*
* @param string $status 'active' to return only pages associated with active components, 'all' to return all saved
* pages. When running save routines, use 'all' to avoid removing data related to inactive
* components. Default: 'active'.
* @return array|string An array of page IDs, keyed by component names, or an
* empty string if the list is not found.
*/
function bp_core_get_directory_page_ids( $status = 'active' ) {
它将返回类似于:
的数组array(4) {
["activity"]=>
int(72)
["members"]=>
int(73)
["register"]=>
int(74)
["activate"]=>
int(75)
}
数组值是WordPress中分配给这些组件的页面ID。