0

I have a page that I am sending users directly to so I can serve them a PDF dynamically created using the FPDF library. Since I'm sending them directly to the file which generates the PDF, I'm rewriting the URL. In the original file I use require_once('wp-load.php') with the correct path in order to load the WordPress environment. It loads perfectly fine and spits out the PDF when I go to website/path/to/file.php?p=foo&q=bar but when I go to website/rewritten?p=foo&q=bar the require_once() function is breaking.

I can tell that my rewrite rule is working properly because when I add debug messages to the file, they are printed when I go to website/rewritten?p=foo&q=bar and using dirname(__FILE__) returns the path of the actual file not the template.

Do I need to change the require path or something to load WordPress properly? I can't seem to figure it out no matter what I try.

2
  • you can handle everything within WordPress and avoid this issue, see this question.
    – Milo
    Jul 2, 2015 at 17:15
  • @Milo Sorry, I think I phrased it poorly. I'm not actually serving them a PDF file that exists on the server. I'm sending them to a page which creates a PDF in browser via some PHP which can then be saved/printed. It's actually the FPDF library if that has any bearing on the situation. I'll update my question to reflect that. I'm not sure if your solution would be applicable in this case but I can try.
    – mcon
    Jul 2, 2015 at 17:21

1 Answer 1

0

If anyone is wondering I figured it out. Since I was hosting my WordPress site on a Chassis server, the path I needed to use in my require statement was different than the actual path on my machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.