Then was fulfilled that which was spoken by Jeremy the prophet, saying, And they took the thirty pieces of silver, the price of him that was valued, whom they of the children of Israel did value;
Note 10 at Mt 27:9: The closest Old Testament passage to what was being quoted here is found in Zec 11:12-13, not in Jeremiah. This looks like a human mistake on Matthew's part in citing the correct author and throws doubt on whether Matthew was really inspired in writing this Gospel. There could be a number of explanations that would still maintain the inspiration and infallibility of the Scriptures.
First, there are some differences between the text of Zec 11:12-13 and the quotation here, so it is not certain that this quotation was from Zechariah. It is possible that Jeremiah did write prophetically concerning this instance, but we no longer have a copy of that manuscript.
It's also possible that Matthew cited some of Jeremiah's writings about the potter (Jer 18:2, 19:1-2, and 32:6-14) and combined them with the prophecy of Zechariah, crediting only the first writer.
There are other explanations, including the possibility that Jeremiah may have authored some of the passages Zechariah used in his prophecy. It cannot be said emphatically what the answer to this apparent discrepancy is. However, it cannot be said emphatically that there is a discrepancy either, when other solutions are possible.