Display single activity on a wordpress page template
-
Wordpress v5.9
Buddypress V10
Theme – Nouveau enabledI’m trying to put the contents of a single activity onto a custom wordpress template page.
e.g. https://www.mysite.com/members/myusername/activity/2/I looked at the \buddypress\bp-templates\bp-nouveau\buddypress\activity\activity-loop and \activity\single\home for code to put in my custom template:
<div class="entry-content" id="start-a-project"> <div id="buddypress" class="buddypress-wrap twentysixteen bp-dir-hori-nav"> <?php $prj_activity_args = array("include"=> 2 ); // only pull activity id=2 from WP_BP_ACTIVITY ?> <div class="activity" data-bp-single="2"> <!--hardcoding for testing--> <?php if ( bp_has_activities( $prj_activity_args ) ) : ?> <?php if ( empty( $_POST['page'] ) || 1 === (int) $_POST['page'] ) : ?> <ul id="activity-stream" class="activity-list item-list bp-list" data-bp-list="activity"> <ul class="activity-list item-list bp-list"> <?php endif; ?> <?php while ( bp_activities() ) : bp_the_activity(); ?> <?php bp_get_template_part( 'activity/entry' );?> <?php endwhile; ?> <?php if ( empty( $_POST['page'] ) || 1 === (int) $_POST['page'] ) : ?> </ul> <!-- .activity-list --> </ul> <!-- #activity-stream --> <?php endif; ?> <?php else : ?> <?php //bp_nouveau_user_feedback( 'activity-loop-none' ); ?> <?php endif; ?> <?php// bp_nouveau_after_loop(); ?> </div> </div>
I only want to pull one activity – so I passed array(“include”=> 2 ) to bp_has_activities() ; However, when the page is loaded, the <ul id=”activity-stream”> loads ALL the activities.
Could someone help me figure out why this is happening? I switched to the legacy theme and the code works fine. I think it’s something to do with the data-bp-list=”activity” that is causing all the activities to get loaded.
- You must be logged in to reply to this topic.