【问题标题】:How to get all WordPress pages associated with BuddyPress?如何获取与 BuddyPress 关联的所有 WordPress 页面?
【发布时间】:2015-10-19 20:06:06
【问题描述】:

如何获取与 BuddyPress 关联的所有 WordPress 页面?我的意思是,我将通过下面的图片详细说明:

每个人都可以根据图片看到有 5 个页面(小部件、测试目的、主页、关于我们、博客),这些是我创建的 WordPress 页面,所有这些页面都分配到 BuddyPress 组件目录。现在我想获得所有这些分配的页面。是否有为此目的的内置函数或有任何策略来获取这些页面?

【问题讨论】:

    标签: php wordpress buddypress


    【解决方案1】:

    您应该能够使用文件bp-core/bp-core-functions.php 中定义的函数bp_core_get_directory_page_ids

    /**
     * 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。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-21
      • 2015-05-02
      • 1970-01-01
      • 2011-12-04
      相关资源
      最近更新 更多