Title: In which file should I write the php header() function?
Last modified: September 17, 2021

---

# In which file should I write the php header() function?

 *  [michalrama](https://wordpress.org/support/users/michalrama/)
 * (@michalrama)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/in-which-file-should-i-write-the-php-header-function/)
 * Hello,
 * I’m solving an issue with downloading a PDF file that the browser tends to open
   instead of downloading it. I found that it could force using the [PHP header() function](https://www.w3schools.com/php/func_network_header.asp),
   but I don’t know what file to write it to? Not to wp-config.php?
 * Please help
 * Thank you

Viewing 1 replies (of 1 total)

 *  [Jacob Peattie](https://wordpress.org/support/users/jakept/)
 * (@jakept)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/in-which-file-should-i-write-the-php-header-function/#post-14882508)
 * Nowhere.
 * In a previous thread you mentioned this: [https://stackoverflow.com/questions/20080341/correct-php-headers-for-pdf-file-download](https://stackoverflow.com/questions/20080341/correct-php-headers-for-pdf-file-download)
   That is not going to help you. It is for an entirely different problem.
 * As you also mentioned in that thread, there is the `download` attribute. If you
   have properly added that attribute (your link should look like `<a href="url/
   to/pdf/here.pdf" download>Download</a>`) then the PDF will download instead of
   open directly. If your issue is that then _opening_ the PDF opens it in the browser,
   then there’s nothing you can do about that. That’s browser behaviour, particularly
   in Chrome.
 * There might be a Chrome setting that lets you change this behaviour, but that’s
   not something you can force for other users.

Viewing 1 replies (of 1 total)

The topic ‘In which file should I write the php header() function?’ is closed to
new replies.

## Tags

 * [file](https://wordpress.org/support/topic-tag/file/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [header](https://wordpress.org/support/topic-tag/header/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Jacob Peattie](https://wordpress.org/support/users/jakept/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/in-which-file-should-i-write-the-php-header-function/#post-14882508)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
