$paged = ( isset( $_GET['page'] ) ) ? $_GET['page'] : 1; $custom_query_args = array( 'post_type' => 'video', 'paged' => $paged, 'author' => bp_displayed_user_id(), 'posts_per_page' => get_option( 'posts_per_page' ) ); $custom_query = new WP_Query( $custom_query_args ); $temp_query = $wp_query; $wp_query = NULL; $wp_query = $custom_query; if ( $custom_query->have_posts() ) : while ( $custom_query->have_posts() ) : $custom_query->the_post(); get_template_part( 'loop', 'video' ); endwhile; ?> </div> <ul class="pagination"> <?php // echo videos_profile_pagination( $wp_query ); $list = videos_profile_pagination($custom_query); foreach ( $list as $page ) { echo "<li>$page</li>"; } ?> </ul> <?php add_action('mars_pagination', 'mars_pagination', 10, 1); wp_reset_query(); endif; ?> <?php // Reset main query object $wp_query = NULL; $wp_query = $temp_query; ?> </div> </div><!-- /.row --> </div> </div><!-- /.container --> <?php } pagination for profile video loop page function videos_profile_pagination( $wp_query ) { $query = $wp_query; if ( $query->max_num_pages < 2 ) { return; } $paged = ( isset( $_GET['page'] ) ) ? $_GET['page'] : 1; // Set up paginated links. $links = paginate_links( array( 'base' => '%_%', 'format' => '?page=%#%', 'total' => $query->max_num_pages, 'current' => $paged, 'mid_size' => 3, 'type' => 'array', 'prev_next' => true, 'prev_text' => !is_rtl() ? __( '← Previous ', 'mars' ) : __( ' → Previous', 'mars' ), 'next_text' => !is_rtl() ? __( 'Next →', 'mars' ) : __( 'Next ←', 'mars' ) ) ); return $links; }