I'm using Buddypress for wordpress and I'm trying to show a loop on the profile page of a user. I use infinite scroll to load more pages but the link to page 2 doesn't point to a group of posts and instead takes me to a blank page template but I do get this link.


Any ideas on how to make this page correctly? The following snippet is placed in the profile-loop.php.

  global $bp;
  global $paged;
  global $wp_query;
  $temp = $wp_query;
  $wp_query = null;
  $user_id = $bp->displayed_user->id;
  $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  $args = array(
        'posts_per_page' => 16,
        'cat' => -1,
        'post_type' => array( 
        'author' => $user_id,
        'paged' => $paged
  $wp_query = new WP_Query($args);
  while ( $wp_query->have_posts() ) :   $wp_query->the_post();
     get_template_part( 'loop', 'contents' );
  echo '<div class="infinitescroll">';
  echo '</div>';
  $wp_query = null; $wp_query = $temp;
<script type="text/javascript">
var href = 'first';
$(document).ready(function() {
        loading: {
          finished: undefined,
          finishedMsg: '',
          img: '',
          msgText: '',
          speed: 'fast',
          start: undefined
        navSelector: '.infinitescroll',
        nextSelector: '.infinitescroll a',
        itemSelector: '#boxes .box',
        bufferPx     : 120,
        debug: false
    }, function(arrayOfNewElems) {
       var $newElems = $( arrayOfNewElems ).css({opacity: 0});
        $newElems.animate({opacity: 1});
        $('#boxes').masonry('appended', $newElems, true);
        if(href != $('.infinitescroll a').attr('href')) {
            href = $('.infinitescroll a').attr('href');

2 Answers 2


(btw hi boone, im jacob, from vancouver). ( keyword "nice!" :)

I am facing the exact same problem. Your implementation of the infinitescroll plugin seems ok. but it doesn seem to be an inifinitescroll prob to me. btw I disabled it, by simply uncommenting my item container and when i try to navigate through the pages with my navigation links, as soon as i get on page 2 I have a 404 (which is exactly what firebugs spits in the console, if you have the infinitescroll turned on)

I have setup my loop as Pollux did.

If I retrieve the page param via a

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

from members/single/home.php I get

"Call to a member function get() on a non-object" error.

So for now, I just disabled the page param and managed to make it work by going into permalink settings and putting them back to the default /?p=123

I can now access home.php via the URL /members/USER and get a nice view of the buddypress profile, with all the user´s posts listed next to it. It nicely moves over to ?paged=2,3,4,5,etc. and also infinitescroll can handle everything.

This is no solution though, as I terribly need permalinks to be structured per /sample-post/ and buddypress even expects me to do that.

I am relatively new to the world of wordpress and buddypress and thus only can share my experience til now. I still hope Boon or somebody else might get enlightend by this experience.

nice greetings,


  • This is obviously a wp_rewrite issue. I have the same issue but with bbPress, pagination was not working on user profile with pretty permalinks /forums/users/username/page/2/, but works fine with default settings /?bbp_user=1&paged=2. Unfortunately my knowledge in that subject is limited, but I know that a new rewrite rule must be added so that server will recognize the pagination on pretty permalinks.
    – Ahmad M
    Nov 20, 2012 at 18:32

I'm not sure how your infinite scroll script interacts with WP_Query. But the root problem appears to be that you're not providing a paged parameter for WP_Query, which is the parameter responsible for setting which page you're looking at. If you don't provide such a parameter, it defaults to 1, which would describe the behavior you're seeing.

  • Thx Boone for answering. How would you go about setting up the loop? I added 'paged' => get_query_var('page') but it didn't help. Was that what you meant? You can see the new loop above in the update. I tried both "page" and "paged". Apr 13, 2012 at 1:23
  • It's not really possible for me to say, without knowing more about how you're implementing infinite scroll. Apr 13, 2012 at 14:11
  • Basically I'm using the jquery masonry and infinite scroll jquery plugins to list posts. I have a loop that I run using the same template on my index page for all recent posts for my site and that works perfectly Which made me curious so I took out 'author' => $user_id from this loop and ran it on the index page and it worked perfectly. But that same loop on a profile page still only triggers the first page. You can see the script I use to trigger infinite scroll above in the example. Apr 13, 2012 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.