How to create multiple pages for PDFs

If you really want to include them in a page, you could create a page template which pulls in the requested PDF by ID. So for example, you create the Page www.example.com/pdf/ and add a query string so when someone visits www.example.com/pdf/?id=234 they see the PDF which has a post ID of 234. Within the Page Template, you’d check

// make sure id is present in the url
if(!empty($_GET['id'])) {
wp_get_attachment_url( $id );
    // get the url to the pdf
    $pdf = wp_get_attachment_url( $_GET['id'] );
    // now add your desired code to embed/link/display the pdf
}

Depending on your needs, perhaps you don’t really need a Page wrapped around the PDFs. You could instead just link directly to the PDFs since most modern browsers will navigate to them and display them in a more flexible, responsive way than embedding them within a Page. With this approach, if you need a link to every PDF, you could create a Page Template that instead searches for all media where the file type is PDF, then have a foreach loop that links to the specific URL. You’d just want to make sure that each PDF within the Media Library has a decently readable Title so the text of the link makes sense.

tech