我想显示特定WordPress页面的PDF,该页面按(月份)名称过滤。e、 g:检查当前月份(十月)并显示十月。pdf。所有PDF文档都将从管理面板上载,我想在前端的页面中动态显示当前月份的PDF。
以下是我尝试的代码:
<?php
//Get the full textual representation of current month in lower case
$months = strtolower (date(\'F\'));
//Convert the current month name to PDF file location
$filename = \'/wp-content/uploads/2020/10/\'. $months.\'.pdf\';
if (file_exists($filename)) {
// Header content type
header("Content-type: application/pdf");
header("Content-Length: " . filesize($filename));
// Send the file to the browser.
readfile($filename);
} else {
// echo \'False \';
// die;
}
?>