Blogs Loop
NOTE: This will only work with an installation of BuddyPress and WordPress MU or WordPress with multisite enabled.
The site blogs loop can be used to output a list of blogs that have been created on your installation.
Standard Loop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <?php if ( bp_has_blogs() ) : ?> <div class = "pagination" > <div class = "pag-count" id= "blog-dir-count" > <?php bp_blogs_pagination_count() ?> </div> <div class = "pagination-links" id= "blog-dir-pag" > <?php bp_blogs_pagination_links() ?> </div> </div> <ul id= "blogs-list" class = "item-list" > <?php while ( bp_blogs() ) : bp_the_blog(); ?> <li> <div class = "item-avatar" > <a href= "<?php bp_blog_permalink() ?>" ><?php bp_blog_avatar( 'type=thumb' ) ?></a> </div> <div class = "item" > <div class = "item-title" ><a href= "<?php bp_blog_permalink() ?>" ><?php bp_blog_name() ?></a></div> <div class = "item-meta" ><span class = "activity" ><?php bp_blog_last_active() ?></span></div> <?php do_action( 'bp_directory_blogs_item' ) ?> </div> <div class = "action" > <div class = "generic-button blog-button visit" > <a href= "<?php bp_blog_permalink() ?>" class = "visit" title= "<?php _e( 'Visit Blog', 'buddypress' ) ?>" ><?php _e( 'Visit Blog' , 'buddypress' ) ?></a> </div> <div class = "meta" > <?php bp_blog_latest_post() ?> </div> <?php do_action( 'bp_directory_blogs_actions' ) ?> </div> <div class = "clear" ></div> </li> <?php endwhile ; ?> </ul> <?php do_action( 'bp_after_directory_blogs_list' ) ?> <?php bp_blog_hidden_fields() ?> <?php else : ?> <div id= "message" class = "info" > <p><?php _e( 'Sorry, there were no blogs found.' , 'buddypress' ) ?></p> </div> <?php endif ; ?> |
Accepted Parameters
The bp_has_blogs()
function will accept a number of parameters that will manipulate the data being returned.
-
type optional
Defines the type of blogs to return.
- Accepted arguments:
active
,newest
,random
- Default value:
active
- Accepted arguments:
-
per_page optional
The number of blogs to display on a page before they are paginated to the next page.
- Default value:
10
- Default value:
-
page optional
The page to return.
- Default value:
1
- Default value:
-
max optional
The total number of blogs to return.
- Default value:
false
(no limit)
- Default value:
-
user_id optional
Return only blogs that this user has higher than subscriber access to.
- Default value:
false
- Default value:
-
search_terms optional
Return only blogs that match these search terms.
- Default value:
false
- Default value: