bp_blogs_get_blogs( array|string $args = '' )

Retrieve a set of blogs.

Description

See also

Parameters

$args

(Optional) Arguments are listed here with their default values. For more information about the arguments, see BP_Blogs_Blog::get().

  • 'type'
    (string) Default: 'active'.
  • 'user_id'
    (int|bool) Default: false.
  • 'include_blog_ids'
    (array) Default: false.
  • 'search_terms'
    (string|bool) Default: false.
  • 'per_page'
    (int) Default: 20.
  • 'page'
    (int) Default: 1.
  • 'update_meta_cache'
    (bool) Whether to pre-fetch blogmeta. Default: true.

Default value: ''

Return

(array) See BP_Blogs_Blog::get().

Source

File: bp-blogs/bp-blogs-functions.php

function bp_blogs_get_blogs( $args = '' ) {

	// Parse query arguments.
	$r = bp_parse_args( $args, array(
		'type'              => 'active', // 'active', 'alphabetical', 'newest', or 'random'
		'include_blog_ids'  => false,    // Array of blog IDs to include
		'user_id'           => false,    // Limit to blogs this user can post to
		'search_terms'      => false,    // Limit to blogs matching these search terms
		'per_page'          => 20,       // The number of results to return per page
		'page'              => 1,        // The page to return if limiting per page
		'update_meta_cache' => true      // Whether to pre-fetch blogmeta
	), 'blogs_get_blogs' );

	// Get the blogs.
	$blogs = BP_Blogs_Blog::get(
		$r['type'],
		$r['per_page'],
		$r['page'],
		$r['user_id'],
		$r['search_terms'],
		$r['update_meta_cache'],
		$r['include_blog_ids']
	);

	/**
	 * Filters a set of blogs.
	 *
	 * @since BuddyPress 1.2.0
	 *
	 * @param array $blogs Array of blog data.
	 * @param array $r     Parsed query arguments.
	 */
	return apply_filters( 'bp_blogs_get_blogs', $blogs, $r );
}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.