How to: Pagination on a customized friends list
-
I have a custom buddypress friends list page that displays the friends videos and I’ve set my per_page to 50. How can I paginate the friends list in the event a user has more than 50 friends?
<div class="dashboard-wrapper"> <h1>My Friends' Videos</h1> <a href="?part=default" class="button">Dashboard</a><br> <?php $user_id = bp_is_user() ? bp_displayed_user_id() : bp_loggedin_user_id(); $args = apply_filters('bp_show_friends_args', array( 'user_id' => $user_id, 'type' => 'active', 'per_page' => 50, 'max' => $limit, 'populate_extra' => 0 ) ); if (bp_has_members($args)) { ?> <ul class="bpsf-members"> <?php while (bp_members()) : bp_the_member(); ?> <li class="bpsf-member"> <?php bp_member_name(); ?> <div class="item-avatar"> <a href="<?php bp_member_permalink() ?>" title="<?php bp_member_name(); ?>"> <?php bp_member_avatar($avatar_args) ?><?php display_friend_colors(bp_get_member_user_id()); ?> </a> </div> <?php do_action('bp_show_friends_after_friend_avatar', bp_get_member_user_id()); ?><div class="cleared"></div> <div class="videos"> <ul> <?php $args = array( 'author' => bp_get_member_user_id(), 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'member_video', 'posts_per_page' => -1 // no limit ); $current_user_posts = get_posts($args); foreach ($current_user_posts as $post) : setup_postdata($post); $thumbnail = get_post_meta(get_the_ID(), 'thumbnail'); //d($thumbnail); ?> <li> <a href="<?php the_permalink(); ?>"><img src="<?= $thumbnail[0] ?>" /></a> <p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p> </li> <?php endforeach; wp_reset_postdata(); ?> </ul> </div> <div class="cleared"></div> </li> <?php endwhile; ?> </ul> <?php } ?>
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.