What you mentioned above is seems as Encopresis
Offer age-appropriate positive reinforcement for developing regular toilet habits
Plenty of water
Proper and Regular Diet(Break fast/ lunch/Snacks/Dinner)
Diet contain High Fiber (whole grain, Fruits, Vegetables etc)
Encourage to your child to spend more time in toilet.
Encourage for defecation after each meals.
I wish your child good health