Skip to:
Content
Pages
Categories
Search
Top
Bottom

Pagination won't work on query within buddypress profile


  • piratescott
    Participant

    @piratescott

    Ok so I’m attempting to display the users posts on their profiles, it’s all working with the exception of pagination, it just says that the page cannot be found and theres a button to return to the original page.

    The code I have is below.

    if ( !function_exists( 'add_action' ) ) {
    
    	echo '404';
    
    	exit;
    
    }
    
    define('bpShowPosts', '1.0');
    
    define('bpShowPosts_PLUGIN_URL', plugin_dir_url( __FILE__ ));
    
    function my_setup_nav() {
    
          global $bp;
    
     
    
          bp_core_new_nav_item( array( 
    
            'name' => __( 'Posts', 'buddypress' ), 
    
            'slug' => 'my-posts', 
    
            'position' => 75,
    
            'screen_function' => 'my_posts_link',
    
    	    'show_for_displayed_user' => true,
    
    	    'default_subnav_slug' => 'my-posts',
    
    	    'item_css_id' => 'my-posts'
    
          ) );
    
    }
    
     
    
    add_action( 'bp_setup_nav', 'my_setup_nav', 1000 );
    
     
    
    function my_posts_title() {
    
    	echo bp_displayed_user_username() . '\'s posts';
    
    }
    
     
    
    function my_posts_content() {
        $the_users_id = $bp->displayed_user->id;
    	
        //The Query
        query_posts('author=$the_users_id');
    
        //The Loop
        if ( have_posts() ) : while ( have_posts() ) : the_post();
        echo '<div id="bp_user_posts">';
        echo '<ul class="bp_user_post_image">';
        echo '<a href="' . get_permalink() . '">';
        the_post_thumbnail(thumbnail);
        echo '</a>';
        echo '</ul><ul class="bp_user_post_content"><li class="bp_user_post_title">';
        echo '<a href="' . get_permalink() . '"><h3>';
        the_title();
        echo '</h3></a>';
        echo '</li><li class="bp_user_post_excerpt">';
        echo '<a href="' . get_permalink() . '">';
        the_excerpt();
        echo '</a></li></ul></div>';
    
        endwhile; 
    
    echo '<div class="nav-previous alignleft">' . next_posts_link( 'Older posts' ) . '</div>';
    echo '<div class="nav-next alignright">' . previous_posts_link( 'Newer posts' ) . '</div>';
    
    else:
        echo "The user has not contributed anything!";
        endif;
    
    //Reset Query
    wp_reset_query();
    
    }
    
    function my_posts_link () {
    
    	add_action( 'bp_template_title', 'my_posts_title' );
    
    	add_action( 'bp_template_content', 'my_posts_content' );
    
    	bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
    
    }
    
    ?>

    Any help would be greatly appreciated

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Pagination won't work on query within buddypress profile’ is closed to new replies.
Skip to toolbar