Our three-year-old wasn't pooping regularly, which caused a lot of concern. Eventually we were going to go to the hospital for a thorough set of tests and what not, after about 4 months of once-per-week pooping. There are many potential causes and this behavior is not uncommon in 2-6 year olds.
Possible things to try: diet (dairy, wheet, rice, banana alergies or food sensitivities), magnesium, probiotics (symboflora), warm apple juice, prune juice, dried apricots/prunes, kiwi fruit, dark karo syrup/brown sugar/dextrose, omega-3, getting him to sit on the toilet for up to 30 minutes at the same time every day, etc., etc.
We tried some of these (many of these), and at one point did try a glycerine rectal enema, though really it was for me a last resort sort of thing. Eventually it really came down to a psychological issue: he didn't like pooping, didn't want to poop, and therefore tried not to (with some definite success). The change only came through talking about pooping, that it is normal, that it hurts sometimes, but that it is normal and everyone does it, and he has to, otherwise it can hurt him (more than actually pooping does).
That was it. All the trial and error, drama, and constant worry (on his mother's part) and having to put up with the worry, the constant tension, etc.
Now pooping is normal, 1-2x/day, quite regularly after breakfast (when the whole family generally does this: mom, dad, and baby brother (1-year old).