To achieve adaptive gait planning of humanoid robots, a hierarchical central pattern generator (H-CPG) model with a basic rhythmic signal generation layer and a pattern formation layer is proposed to modulate the center of mass (CoM) and the online foot trajectory. The entrainment property of the CPG is exploited for adaptive walking in the absence of a priori knowledge of walking conditions, and the sensory feedback is applied to modulate the generated trajectories online to improve walking adaptability and stability. The developed control strategy is verified using a humanoid robot on sloped terrain and shows good performance.