handling attachments redirections
This commit is contained in:
parent
66b1a36a1d
commit
71a2d6118a
|
|
@ -1 +0,0 @@
|
||||||
<h1>salut</h1>
|
|
||||||
18
attachment.php
Normal file
18
attachment.php
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
$attachment_id = get_the_ID();
|
||||||
|
$title = get_the_title();
|
||||||
|
$document_permalink = get_the_permalink(get_the_ID());
|
||||||
|
$pdf_url = wp_get_attachment_url(get_the_ID());
|
||||||
|
|
||||||
|
|
||||||
|
if ($pdf_url) {
|
||||||
|
wp_redirect($pdf_url);
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
// Si l'URL du document est vide, redirige vers la page 404
|
||||||
|
global $wp_query;
|
||||||
|
$wp_query->set_404();
|
||||||
|
status_header(404);
|
||||||
|
get_template_part(404);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user