Like most types of animals – the best way to train them to respect electric fence is to build a training pen or yard, in which they will be exposed to the fence wire, get a shock and retain a lasting memory. Do not crowd or force them into the wire, but rather, just let them discover it for themselves.
The fence voltage on this training area should be sufficient for a lasting impression. Voltage of 6KV should do the trick, but more is better.
For pigs, 3 or 4 strands of wire are adequate. For baby piglets, a vertical wire spacing of 4” might be required to keep them from going under or through. For weanlings, a spacing of 6” to 8” will work. A pig’s normal course would be to go under or through the fence, but rarely would they attempt to jump it. So proper vertical wire spacing is important in relation to the size of the pig being trained.
In essence, you want them to get shocked as they come in contact with the wire upon approach, rather than get shocked after they are over half way through. If shocked upon approach they will likely jump back. However, if they get shocked after they are halfway through, they may bolt forward.
Usually only a few hours in the training area is necessary. Just remember that you want this first exposure to electric shock to leave a lasting impression, so the fence needs to be hot.