Skip to:
Content
Pages
Categories
Search
Top
Bottom

Pagination for Custom Loop in New BuddyPress Tab


  • seriouslightbox
    Participant

    @seriouslightbox

    Hello, I successfully created a new BuddyPress Profile Tab called “Videos”. This page shows all videos shared by that user (custom post type called “video”). It also shows the pagination, however, once the pagination is clicked, it brings me to a 404 page. Here’s what I have so far:

    function my_videos_screen_content() { 
        echo 'We are currently working on this section, some content may not appear properly. Thank you for your patience.'; ?>
    	<div class="container">
        		<div class="row">
    			<div class="col-sm-8">
                	<div class="row video-section meta-maxwidth-230">
    	<?php 
    	
    	$custom_query_args = array(
            'post_type'         => 'video',
            'author'            => bp_displayed_user_id(),
    		'posts_per_page'    => get_option( 'posts_per_page' )
            );
    	
    	$custom_query_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
    	
    	$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>
    		<?php endif; 
    		wp_reset_postdata(); ?>
    	    
    	    <?php // Custom query loop pagination
            previous_posts_link( 'Newer Videos' );
            next_posts_link( 'Older Videos', $custom_query->max_num_pages );?>
            
            <?php // Reset main query object
            $wp_query = NULL;
            $wp_query = $temp_query; ?>
    
    			</div>
    		</div><!-- /.row -->
    	</div>
    	</div><!-- /.container -->   
    <?php }

    NOTES:
    Wordpress Version : Latest
    BuddyPress Version : Latest
    Theme : VideoTube

    Any help would be greatly appreciated – thanks!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar