Skip to:
Codex HomeDeveloper ResourcesLoops Reference → Blogs Loop

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

<?php if ( bp_has_blogs() ) : ?>

	<div class="pagination">

		<div class="pag-count" id="blog-dir-count">
			<?php bp_blogs_pagination_count() ?>

		<div class="pagination-links" id="blog-dir-pag">
			<?php bp_blogs_pagination_links() ?>


	<ul id="blogs-list" class="item-list">
	<?php while ( bp_blogs() ) : bp_the_blog(); ?>

			<div class="item-avatar">
				<a href="<?php bp_blog_permalink() ?>"><?php bp_blog_avatar('type=thumb') ?></a>

			<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 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 class="meta">
					<?php bp_blog_latest_post() ?>

				<?php do_action( 'bp_directory_blogs_actions' ) ?>

			<div class="clear"></div>

	<?php endwhile; ?>

	<?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>

<?php endif; ?>

Accepted Parameters

The bp_has_blogs() function will accept a number of parameters that will manipulate the data being returned.

Skip to toolbar