Placing activity loop in a new page using shortcode
-
Hi!
I am trying to create a shortcode to place the activity loop in a new page, so I can customize and highlight some activities. To start, I inserted the standard loop inside a shortcode function (code as below). But the standard loop failed to show. Just to ensure that my shortcode is ok, I just inserted a “testing 123” text to check.
FYI, I am using BuddyX theme (WordPress version 5.8.3). I test the code below in functions.php before place it into Code Snippets plugin. Currently, the code is still inside functions.php.
I placed the shortcode ([mkp_activity]) in a page (link to the page as below). I also try to place the shortcode in widget area. But the loop just did not appear.
function mkp_bp_activity_shortcode() { $message = 'testing 123'; return $message; if ( bp_has_activities( bp_ajax_querystring( 'activity' ) ) ) : while ( bp_activities() ) : bp_the_activity(); locate_template( array( 'activity/entry.php' ), true, false ); endwhile; endif; } add_shortcode('mkp_activity', 'mkp_bp_activity_shortcode');
I am new to this. I am not sure if I am doing this completely wrong. Appreciate any advice. Thanks!
Regards,
CK
- You must be logged in to reply to this topic.