Skip to content

Instantly share code, notes, and snippets.

@vapvarun
Last active September 4, 2025 12:10
Show Gist options
  • Select an option

  • Save vapvarun/3f4b05ad8bab92931a09f5ed55ff31ff to your computer and use it in GitHub Desktop.

Select an option

Save vapvarun/3f4b05ad8bab92931a09f5ed55ff31ff to your computer and use it in GitHub Desktop.
WP Stories - Display Stories Grouped by Users on Activity Pages
<?php
/**
* WP Stories - Display Stories Grouped by Users on Activity Pages
*
* This code snippet modifies the default story display on BuddyPress and PeepSo
* activity pages to show stories grouped by users (public type) instead of
* showing all stories mixed together (single type).
*
* Add this code to your theme's functions.php file or create a custom plugin.
*
* @version 1.2.0
*/
// Prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Override the wb-story-activities shortcode to display grouped stories
* This method intercepts the shortcode output and replaces it with grouped display
*/
add_filter( 'do_shortcode_tag', 'wp_stories_override_activity_shortcode', 10, 4 );
function wp_stories_override_activity_shortcode( $output, $tag, $attr, $m ) {
// Only modify the wb-story-activities shortcode
if ( 'wb-story-activities' !== $tag ) {
return $output;
}
// Check if we're on BuddyPress activity page
if ( function_exists( 'bp_is_activity_directory' ) && bp_is_activity_directory() ) {
// Replace with grouped stories display for BuddyPress
return do_shortcode( '[wb-user-stories type="public"]' );
}
// Check if we're on PeepSo activity page (multiple ways to check)
if ( class_exists( 'PeepSo' ) ) {
$is_peepso_activity = false;
// Method 1: Check URL parameter
if ( isset( $_GET['section'] ) && 'activity' === $_GET['section'] ) {
$is_peepso_activity = true;
}
// Method 2: Check if on PeepSo activity page using their functions
if ( function_exists( 'peepso_is_current_page' ) && peepso_is_current_page( 'activity' ) ) {
$is_peepso_activity = true;
}
if ( $is_peepso_activity ) {
// Replace with grouped stories display for PeepSo
return do_shortcode( '[wb-user-stories type="public"]' );
}
}
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment