List all files from subpages

My goal is to list all the pages names as well as the attached files of these pages on a separate overview page in wordpress.

I have 100 pages with each between 0 and 4 attached PDF files (linked inside the content, but could be uploaded as attachement to the page also).

The overview page should then list all these pages like this:

- page name 1
-- pdf file 1-1
-- pdf file 1-2
[..]
- page name 2
-- pdf file 2-1
-- pdf file 2-2
[..]

and so on.

What is the best way to achieve this? Can I collect these linked pdfs with get_attached_file()? or doesn't this work with pages? I'd like to prevent having to maintain the overview list manually.

Bonus question: Is there also a way to collect all the external links on these pages as well?

Topic wp-list-pages attachments Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.