get all page IDs from wp_list_pages
wp_list_pages() is for formatted markup. Use get_pages() and wp_list_pluck(): $pages = get_pages( array ( ‘parent’ => 0, // replaces ‘depth’ => 1, ‘exclude’ => ‘3,5,11’ ) ); $ids = wp_list_pluck( $pages, ‘ID’ ); $ids holds an array of page IDs now.