How to get lowest price from custom fields of posts

Your code is badly broken in a couple of place and potentially flawed in a couple of others.

$price=$post->ID; 
$price = get_post_meta($price, 'price', true);
i0 ($price <= 3500) {
   $minPrice=$price;
  • Line 1: Not broken but why not just use $post->ID? Setting that to a variable named $price is confusing and unnecessary.
  • Line 2: Passing the true parameter means get_post_meta will only return a single value. This will break if there are multiple prices. I don’t know if that is the case.
  • Line 3: if is misspelled. This would be a fatal error. Secondly, your question is about finding the lowest value but you are looking for less than or equal to a static 3500. There is an inconsistency. I am assuming you want the lowest value.
  • Finally: You don’t close the if conditions. There should be a closing }. This is another fatal error.

So, if you are trying to get the lowest value per post do this:

$price = get_post_meta($post->ID, 'price');
$minPrice=min($price);

If you are trying to get the lowest price from all of the posts in your loop do this:

$price = get_post_meta($price, 'price', true);
// initialize $minPrice to some high value before the Loop starts
if ($price < $minPrice) {
    $minPrice=$price;
}