Starting with a toddler
The learning process can be the same for older children as described here for babies but other toilet training approaches - as long as they're implemented in a gentle and loving way - can also be of value. A merged method is available here.
As older children understand much more about the world it is very important to be careful not to coerce them, nor linger on any negative experiences involving toileting. They have big emotions for little people, with less ability to manage them than we think, and they need you to be on their side.
Keep talking to your child to help them learn about the process and make associations. Encourage them to poo near the toilet or potty, even if in the nappy, and keep inviting them to give it a try when they want to in a positive and relaxed tone. Let them be involved in the process by letting them pick where to use the potty or toilet, or which underwear to wear.
If your child is reluctant, try to look at it from their point of view. Consider how you would feel if you had to suddenly pee or poo in a different position and place to what you've been used to all of your life. Maybe you’ve experienced that feeling while on a camping trip?
It takes time to work out which muscles to use to release a pee in certain position. Respect their pace so they can remain comfortable because it can only happen if muscles get relaxed. Its normal and even healthy for the process to be very gradual.
If you are at a place where previous bad experiences have led to them forming a negative association with the toilet and are actually withholding poo or have constipation then that needs to be addressed first with help of your doctor.