add_shortcode( 'get_total_activity_count', 'get_total_activity_count');
function get_total_activity_count(){
global $wpdb;
$total_activity_count = $wpdb->get_var( "SELECT COUNT(*) FROM activity_database_name
WHERE (component = 'activity' OR component = 'groups')
AND type = 'activity_update'
");
return $total_activity_count;
}
And then using this shortcode [get_total_activity_count] to display on the frontend.