If he has developed piles as you have observed you need to consult with your pediatrician asap.
In the meanwhile include fibre in your child's diet with leafy greens, fresh fruits, sprouts, dry fruits etc. These will help soften his stools.
Next Steps
you can also ask your pediatrician to prescribe a laxative for the time being