[buddypress-trac] [BuddyPress Trac] #6801: Filtering custom activity pages with parse_args

buddypress-trac noreply at wordpress.org
Mon Jan 11 16:55:25 UTC 2016


#6801: Filtering custom activity pages with parse_args
--------------------------+------------------------------
 Reporter:  snd26         |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  API           |     Version:  2.4.0
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+------------------------------

Comment (by snd26):

 To recreate this issue:

 1. create a page in admin > pages > new page, such as 'test-1'.

 2. create the file for the new page in the theme directory 'page-
 test-1.php'.

 3. Make this new file `page-test-1.php` look something like this:


 {{{#!php
 <?php

 get_header(); ?>

 <div class="content" id="content">
         <main id="main" class="site-main">

                 <div id="buddypress">

                         <div class="activity">

                                 <?php bp_get_template_part( 'activity
 /activity-loop' ); ?>

                         </div>

                 </div>

         </main>
 </div>

 <?php get_footer(); ?>
 }}}




 5. Now go to yoursite.com/test-1 and this should now have the activity
 loop working OK.

 6. Now to filter this activity loop, add this to your theme's
 functions.php or a plugin file and we'll use the per_page parameter as an
 example:

 {{{#!php
 <?php
 /**
  * Filter activity loop
  */
 function cm_activity_filter_test( $retval ) {

         if ( is_page('test-1') ) {
              $retval['per_page'] = 1;
         }

     return $retval;
 }
 add_filter( 'bp_after_has_activities_parse_args',
 'cm_activity_filter_test' );
 }}}


 7. Now visit yoursite.com/test-1 again and this page will now show 1
 activity item per page due to the above filter. But when you click the
 load more button, it won't show the next 1 item, it will show the next 20
 items (per_page default). When you click the load more button, it no
 longer recognizes the `is_page('test-1')` conditional.

 Note: This conditional works fine though if you remove `bp-templates/bp-
 legacy/js/buddypress.min.js`.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6801#comment:2>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list