How to get top parent page ID in wordpress

The solution to get the top parent page id is here, it is quite easy without using any recursion function. function get_top_parent_page_id() { global $post; // Check if page is a child page (any...