显示最小类别价格

I want to display minimum price for category. Basically need to loop through category product prices and return the minimum.

My code so far what I have tried:

        $cateegory_ids = [20,21,18];
        $query = new WP_Query( array( 'cat' => 20 ) );

        foreach ($cateegory_ids as $value) {
            echo(min($product->get_price()));
        }

you need to pass the list of products to min function and get the min price.

echo(min_price($product));

function min_price($products) {
    $minPrice = null;
    foreach ($products as $oneProduct) {
        if (is_null($minPrice) || $oneProduct->get_price() < $minPrice) 
        {
            $minPrice =  $oneProduct->get_price(); 
        }
    }
    return $minPrice;
}