Below are 10 examples of using the ActivityShortCode with various configurations, combining parameters to achieve specific functionality.
Important Note on max Parameter
When using the max parameter along with the load_more button, max does not limit the number of times you can hit “Load More”. The max parameter will only take effect if it is set to a value less than the default per_page limit.
Shortcode Examples
Example 1: Basic Configuration with Title and Pagination
[activity-listing title="Recent Activities" per_page="5" max="20" load_more="yes"]
- Explanation: Displays “Recent Activities” with 5 items per page, limited to a maximum of 20 activities. Includes a “Load More” button.
Example 2: Group Activities with Ascending Sort Order and Posting Enabled
[activity-listing object="groups" for_group="example-group" sort="ASC" allow_posting="yes"]
- Explanation: Shows only activities related to
example-groupin ascending order, with the option for users to post new activities.
Example 3: User-Specific Activity with Search Filter
[activity-listing user_id="123" display_comments="threaded" search_terms="project update" per_page="10" load_more="no"]
- Explanation: Displays activities for the user with ID
123and filters by “project update”. Shows 10 items per page without a “Load More” button.
Example 4: Activities by Role with Hidden Activities Displayed
[activity-listing role="editor" show_hidden="true" container_class="custom-activity-container" max="15"]
- Explanation: Filters activities to only display those from users with the
editorrole. Shows hidden activities and uses a custom container class.
Example 5: Friend Activity Feed with Posting Enabled
[activity-listing scope="friends" per_page="5" allow_posting="yes"]
- Explanation: Shows activities from friends only, with 5 items per page, and allows users to post new activities.
Example 6: Sorted Activities with Load More Button
[activity-listing sort="DESC" per_page="7" max="14" load_more="yes"]
- Explanation: Displays activities in descending order with a maximum of 14 activities, 7 per page. Includes a “Load More” button.
Example 7: Group Activity with Specific Action Filter
[activity-listing object="groups" for_group="sports-group" action="activity_update" load_more="no"]
- Explanation: Shows activity updates related to
sports-grouponly, without the “Load More” button.
Example 8: Specific Activities Display Using Include and Exclude Parameters
[activity-listing include="101,102,103" exclude="104,105" per_page="5"]
- Explanation: Displays only the activities with IDs 101, 102, and 103 while excluding IDs 104 and 105, showing 5 items per page.
Example 9: Activity Feed for Mentions with Load More and Maximum Limit
[activity-listing scope="mentions" per_page="5" max="10" load_more="yes"]
- Explanation: Displays only mention activities, showing 5 items per page with a maximum of 10 activities. A “Load More” button is included.
Example 10: Customized Container and User ID Filter with Hidden Activities
[activity-listing user_id="456" container_class="custom-feed" show_hidden="true" max="20" allow_posting="yes"]
- Explanation: Filters activities for user ID
456, displays hidden items, limits to 20 activities, and allows posting, with a custom CSS classcustom-feed.
Example 11: Basic Configuration with Title and Pagination
[activity-listing title="Recent Activities" per_page="5" max="20" pagination="yes"]
- Explanation: Displays “Recent Activities” with 5 items per page, limited to a maximum of 20 activities. Includes a “pagination” button.
These examples showcase different ways to configure the ActivityShortCode to tailor activity displays for specific needs. Use these combinations to easily achieve desired functionality within BuddyPress.
