I'm guessing this is a run-of-the mill pressure treated post/rail, and cedar board fence?

1- pressure treated posts should get you 5-10 years of good service and another 5-10 of bad service. Meaning they won't look great, and will be partially rotten but more or less will do the job. The standard Home Depot hem-fir pressure treated posts are not great material.

2- Steel galvanized or powder coated will last longer. You could get the kind with slats in the fence to hide from the neighbors.

3- Nice DF treated posts will last a lot longer at 3x the cost (or more). The stuff that the DOT buys.

4- If you are trying to retain garden soil a 12" retaining wall with the fence on top would be the bees knees.

5- paint or some kind of sealant is generally warranted, and yes, by painting prior to installation you can gain a bit of resistance.

I just built a new fence last summer same type of construction it looks great now (sealed cedar). It will look great in 5 years when I finally paint it. It will look fair 5 years after that when I decide I need to fix it or tear it down. It will look like garbage in 15 years when I finally do.
_________________________
WDFW - Turning outdoorsmen into golfers since 1994.