"He walked past the house, but for the garden."
In this sentence, "but" is used to indicate exception or contrast in relation to the garden. It shows that while he walked past the house, he did so specifically to focus on the garden.
Here's another example:
"She was excited about the trip, but for the long flight."
Again, "but for" highlights an exception to the general excitement.
It's important to note that "but" is primarily a conjunction, connecting words, phrases, or clauses. However, in certain instances, it can function as a preposition, specifically when used in the phrase "but for."