How do i include variable elements in a custom function

I have a function to try and get the count of post for each top level category and its children.

not sure if the function works yet, but I am trying to echo it with bricks builder but I’m not sure how to pass a variable.

I wrote this {echo:get_total_post_count(term_id,‘hobby-category’)}

but if i wanted to include term id, I tried nesting it with a {term_id} also, but that isnot working.

this is my function that chat gpt came up with for this problem

function get_total_post_count($term_id, $taxonomy) {
    $total_count = 0;
    // Get the term and its children
    $term = get_term($term_id, $taxonomy);
    $children = get_term_children($term_id, $taxonomy);
    // Add the count of the current term
    if ($term instanceof WP_Term) {
        $total_count += $term->count;
    // Loop through the children and recursively add their counts
    foreach ($children as $child_id) {
        $child_count = get_total_post_count($child_id, $taxonomy);
        $total_count += $child_count;
    return $total_count;

Nevermind, I think it may be working, I think i cut the function instead of pasting when i posted here.

This appears to work. {echo:get_total_post_count({term_id},‘hobby-category’)}