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
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.