When building a fence you need to decide which strategy you'll go with when it comes to slopes:
- Skew the panels into parallelograms so they follow the slope ("racking" in this image)
- Step the panels down to ground level at the high point for each segment
In either case, post height depends on the height of the panel top at the low end. You want the same extension above the higher panel for each post.
My $.02: I find the step-down approach comically goofy-looking for anything more than a mild slope. They end up looking like sails in the wind and quite inelegant. The steps look wrong and the gaps under the low ends can be very large, reducing the intended benefit of having a fence. I'd skew the panels if possible. A smooth line along the top is much nicer.